/* XIHUA HOLDINGS CMS STUDIO STYLESHEET */
:root {
  --cms-bg-dark: #070c18;
  --cms-bg-sidebar: #091224;
  --cms-bg-card: #0d1b36;
  --cms-bg-card-hover: #122448;
  --cms-bg-input: #081022;
  --cms-border: rgba(0, 194, 255, 0.18);
  --cms-border-focus: #00c2ff;
  --cms-text: #ffffff;
  --cms-text-muted: #8ba3c7;
  --cms-cyan: #00c2ff;
  --cms-blue: #012c71;
  --cms-navy: #041330;
  --cms-green: #10b981;
  --cms-red: #ef4444;
  --cms-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --cms-font-heading: 'Space Grotesk', var(--cms-font);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.cms-body {
  background-color: var(--cms-bg-dark);
  color: var(--cms-text);
  font-family: var(--cms-font);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* TOP APP BAR */
.cms-header {
  height: calc(64px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
  background-color: var(--cms-bg-sidebar);
  border-bottom: 1px solid var(--cms-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 50;
}

.cms-header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.cms-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--cms-text);
}

.cms-brand-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.cms-brand-title {
  font-family: var(--cms-font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cms-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  background: rgba(0, 194, 255, 0.15);
  color: var(--cms-cyan);
  border: 1px solid rgba(0, 194, 255, 0.4);
  border-radius: 4px;
  font-weight: 600;
}

.cms-sync-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--cms-text-muted);
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--cms-text-muted);
}

.status-dot.green {
  background-color: var(--cms-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-dot.yellow {
  background-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.cms-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  border: none;
  line-height: 1;
}

.btn-primary {
  background: linear-gradient(135deg, #00c2ff 0%, #0077b6 100%);
  color: #041330;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(0, 194, 255, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(0, 194, 255, 0.5);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--cms-cyan);
  border: 1px solid rgba(0, 194, 255, 0.4);
}

.btn-outline:hover {
  background: rgba(0, 194, 255, 0.08);
  border-color: var(--cms-cyan);
}

.btn-danger-outline {
  background: transparent;
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--cms-red);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--cms-text);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-auth {
  background: rgba(255, 255, 255, 0.08);
  color: var(--cms-text);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-auth:hover {
  background: rgba(255, 255, 255, 0.14);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 10px;
  border-radius: 20px;
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.user-email {
  font-size: 0.8rem;
  color: var(--cms-text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--cms-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.btn-logout:hover {
  color: var(--cms-red);
}

.hidden {
  display: none !important;
}

/* LAYOUT */
.cms-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* SIDEBAR */
.cms-sidebar {
  width: 260px;
  background-color: var(--cms-bg-sidebar);
  border-right: 1px solid var(--cms-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
}

.cms-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.cms-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--cms-text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  position: relative;
}

.cms-nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--cms-text);
}

.cms-nav-item.active {
  background: rgba(0, 194, 255, 0.12);
  color: var(--cms-cyan);
  font-weight: 600;
  border-left: 3px solid var(--cms-cyan);
}

.nav-icon {
  font-size: 1.1rem;
}

.pill-count {
  margin-left: auto;
  font-size: 0.72rem;
  background: rgba(0, 194, 255, 0.2);
  color: var(--cms-cyan);
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}

.cms-sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.cms-version-tag {
  font-size: 0.7rem;
  color: var(--cms-text-muted);
  line-height: 1.4;
}

/* MAIN CONTENT */
.cms-main {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  background-color: var(--cms-bg-dark);
}

.cms-tab-pane {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
}

.cms-tab-pane.active {
  display: block;
  animation: fadeInTab 0.25s ease;
}

@keyframes fadeInTab {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 16px;
}

.tab-header h2 {
  font-family: var(--cms-font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.tab-subtitle {
  font-size: 0.88rem;
  color: var(--cms-text-muted);
}

/* CARDS & FORMS */
.card-editor {
  background: var(--cms-bg-card);
  border: 1px solid var(--cms-border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--cms-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  background: var(--cms-bg-input);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-family: var(--cms-font);
  font-size: 0.92rem;
  padding: 10px 14px;
  border-radius: 6px;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus {
  border-color: var(--cms-border-focus);
  box-shadow: 0 0 0 3px rgba(0, 194, 255, 0.15);
}

.form-textarea {
  resize: vertical;
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* IMAGE FIELD */
.image-field-wrap {
  display: flex;
  gap: 18px;
  align-items: center;
  background: var(--cms-bg-input);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 14px;
}

.image-preview {
  width: 90px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.image-field-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-upload-label {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  cursor: pointer;
}

.file-upload-input {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* METRICS GRID */
.metrics-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.metric-card-editor {
  background: var(--cms-bg-card);
  border: 1px solid var(--cms-border);
  border-radius: 10px;
  padding: 20px;
  position: relative;
}

.card-num-badge {
  position: absolute;
  top: 14px;
  right: 16px;
  font-family: var(--cms-font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cms-cyan);
  opacity: 0.7;
}

/* ENTITIES GRID */
.entities-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
}

.entity-card-editor {
  background: var(--cms-bg-card);
  border: 1px solid var(--cms-border);
  border-radius: 10px;
  padding: 22px;
}

.bullet-list-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.bullet-item-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-remove-bullet {
  background: none;
  border: none;
  color: var(--cms-text-muted);
  cursor: pointer;
  padding: 4px;
}

.btn-remove-bullet:hover {
  color: var(--cms-red);
}

/* SECTORS GRID */
.sectors-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
}

.sector-card-editor {
  background: var(--cms-bg-card);
  border: 1px solid var(--cms-border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* COMMON COMPONENTS */
.components-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.component-card {
  background: var(--cms-bg-card);
  border: 1px solid var(--cms-border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  transition: border-color 0.2s ease;
}

.component-card.inactive {
  opacity: 0.6;
  border-style: dashed;
}

.comp-details {
  flex: 1;
}

.comp-type-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(0, 194, 255, 0.15);
  color: var(--cms-cyan);
  margin-bottom: 8px;
}

.comp-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.comp-text {
  font-size: 0.88rem;
  color: var(--cms-text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.comp-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* TOGGLE SWITCH */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--cms-cyan);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* DETAIL PAGES */
.detail-pages-editor {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.detail-page-card {
  background: var(--cms-bg-card);
  border: 1px solid var(--cms-border);
  border-radius: 10px;
  padding: 24px;
}

/* ASSET LIBRARY */
.assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.asset-card {
  background: var(--cms-bg-card);
  border: 1px solid var(--cms-border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.asset-card:hover {
  transform: translateY(-2px);
  border-color: var(--cms-cyan);
}

.asset-thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #000;
}

.asset-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.asset-name {
  font-size: 0.76rem;
  color: var(--cms-text-muted);
  word-break: break-all;
  line-height: 1.3;
}

/* MODALS */
.cms-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 19, 48, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cms-modal.open {
  display: flex;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.cms-modal-content {
  background: var(--cms-bg-sidebar);
  border: 1px solid var(--cms-border);
  border-radius: 12px;
  max-width: 650px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.cms-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cms-modal-header h3 {
  font-family: var(--cms-font-heading);
  font-size: 1.2rem;
  color: #fff;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--cms-text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #fff;
}

.cms-modal-body {
  padding: 24px;
  overflow-y: auto;
}

.assets-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.picker-asset-item {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #000;
  display: flex;
  flex-direction: column;
}

.picker-asset-item:hover {
  border-color: var(--cms-cyan);
  box-shadow: 0 0 12px rgba(0, 194, 255, 0.4);
}

.picker-asset-thumb {
  width: 100%;
  height: 90px;
  object-fit: cover;
}

.picker-asset-label {
  padding: 6px;
  font-size: 0.68rem;
  color: var(--cms-text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* TOAST */
.cms-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--cms-bg-card);
  border: 1px solid var(--cms-cyan);
  box-shadow: 0 8px 24px rgba(0, 194, 255, 0.3);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 200;
  display: none;
  align-items: center;
  gap: 10px;
  animation: slideToast 0.3s ease;
}

.cms-toast.show {
  display: flex;
}

@keyframes slideToast {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .cms-layout {
    flex-direction: column;
  }
  .cms-sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--cms-border);
  }
  .cms-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
  }
  .cms-nav-item {
    white-space: nowrap;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}
