/* Platform - Design System (Blue & Orange) */

:root {
  --orange: #FF6B2B;
  --orange-dark: #D95820;
  --orange-light: #FF8F5E;
  --bg-dark: #060D1B;
  --bg-card: #0B1628;
  --bg-sidebar: #070C18;
  --glass-bg: rgba(255, 107, 43, 0.05);
  --glass-border: rgba(255, 107, 43, 0.18);
  --glass-border-subtle: rgba(255, 255, 255, 0.07);
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-muted: rgba(255, 255, 255, 0.4);
  --shadow-deep: 0 8px 32px rgba(0, 0, 0, 0.7);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-orange: 0 4px 24px rgba(255, 107, 43, 0.3);
  --blue-accent: #1E3A6E;
  --blue-glow: rgba(30, 58, 110, 0.4);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Glass cards */
.glass {
  background: var(--bg-card);
  border: 1px solid var(--glass-border-subtle);
  border-radius: 16px;
  box-shadow: var(--shadow-deep);
}

.glass-light {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border-subtle);
  border-radius: 12px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

.text-large { font-size: 1.5rem; }
.text-small { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

/* Numbers */
.number-large {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--orange);
  line-height: 1;
}

.number-medium {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--orange-light);
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: var(--shadow-orange);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--orange-light), var(--orange));
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(255, 107, 43, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--orange);
  color: var(--orange-light);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 107, 43, 0.15);
  background: rgba(255, 107, 43, 0.04);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
}

.form-select {
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  cursor: pointer;
}

.form-select option {
  background-color: #0B1628;
  color: #f9fafb;
}

/* Cards */
.card {
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--glass-border-subtle);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

/* Layout */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--glass-border-subtle);
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 260px;
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(255, 107, 43, 0.08);
  padding: 1.5rem 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--glass-border-subtle);
  margin-bottom: 1.5rem;
}

.sidebar-logo h1 {
  font-size: 1.25rem;
  color: var(--orange);
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-logo p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  flex: 1;
}

.sidebar-nav-item {
  margin: 2px 0;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  font-size: 0.9rem;
}

.sidebar-nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 107, 43, 0.06);
  border-left-color: rgba(255, 107, 43, 0.4);
}

.sidebar-nav-link.active {
  color: var(--orange);
  background: rgba(255, 107, 43, 0.1);
  border-left-color: var(--orange);
  font-weight: 500;
}

.sidebar-nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-divider {
  margin: 1rem 1.5rem;
  border: none;
  border-top: 1px solid var(--glass-border-subtle);
}

.sidebar-section-label {
  padding: 0 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* Main Content */
.main-content {
  margin-left: 260px;
  padding: 2rem;
  min-height: 100vh;
}

/* Top Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--glass-border-subtle);
  margin-bottom: 2rem;
  border-radius: 12px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Tables */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.table th {
  text-align: left;
  padding: 0.875rem 1rem;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--glass-border-subtle);
  white-space: nowrap;
}

.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.table tr:hover td {
  background: rgba(255, 107, 43, 0.03);
}

.table tr:last-child td {
  border-bottom: none;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.5rem;
  border-left: 3px solid var(--orange);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--orange);
  line-height: 1;
}

.stat-change {
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.stat-change.positive { color: #22c55e; }
.stat-change.negative { color: #ef4444; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.badge-warning {
  background: rgba(255, 107, 43, 0.15);
  color: var(--orange-light);
  border: 1px solid rgba(255, 107, 43, 0.3);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-info {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.25);
}

.badge-yellow {
  background: rgba(255, 107, 43, 0.15);
  color: var(--orange);
  border: 1px solid rgba(255, 107, 43, 0.3);
}

/* Loading — fallback spinner (only for initial HTML load) */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 107, 43, 0.2);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Skeleton loader ── */
.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.07) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: skeletonShimmer 1.6s ease-in-out infinite;
}
@keyframes skeletonShimmer {
  to { transform: translateX(100%); }
}
.skeleton-card { padding: 1.5rem; }

/* ── Page transition ── */
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-enter {
  animation: pageFadeIn 0.22s ease-out both;
}

/* ── Empty State ── */
@keyframes emptyFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
  animation: emptyFadeIn 0.3s ease-out both;
}

.empty-state svg,
.empty-state [data-lucide] {
  display: block !important;
  width: 44px !important;
  height: 44px !important;
  margin: 0 auto 1.25rem !important;
  color: var(--orange) !important;
  opacity: 0.22 !important;
}

.empty-state h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Optional icon box wrapper */
.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(255, 107, 43, 0.06);
  border: 1px solid rgba(255, 107, 43, 0.1);
  margin: 0 auto 1.5rem;
  color: var(--orange);
}

/* Alerts */
.alert {
  padding: 1rem 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  border-left: 4px solid;
  font-size: 0.9rem;
}

.alert-success {
  background: rgba(34, 197, 94, 0.08);
  border-color: #22c55e;
  color: #22c55e;
}

.alert-error {
  background: rgba(239, 68, 68, 0.08);
  border-color: #ef4444;
  color: #ef4444;
}

.alert-warning {
  background: rgba(255, 107, 43, 0.08);
  border-color: var(--orange);
  color: var(--orange-light);
}

.alert-info {
  background: rgba(96, 165, 250, 0.08);
  border-color: #60a5fa;
  color: #60a5fa;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--bg-card);
  border: 1px solid rgba(255, 107, 43, 0.15);
  border-radius: 16px;
  padding: 2rem;
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-deep), 0 0 60px rgba(255, 107, 43, 0.05);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--glass-border-subtle);
}

.modal-title {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.5rem;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* CRM Category Tags */
.category-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  background: rgba(255, 107, 43, 0.12);
  color: var(--orange-light);
  border: 1px solid rgba(255, 107, 43, 0.25);
}

/* Manuals */
.manual-card {
  padding: 1.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.manual-card:hover {
  border-left-color: var(--orange);
  background: rgba(255, 107, 43, 0.04);
}

.manual-content {
  line-height: 1.8;
  color: var(--text-primary);
}

.manual-content h1,
.manual-content h2,
.manual-content h3 {
  color: var(--orange-light);
  margin-top: 1.5rem;
}

.manual-content h1 { font-size: 1.8rem; }
.manual-content h2 { font-size: 1.4rem; }
.manual-content h3 { font-size: 1.1rem; }

.manual-content p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.manual-content ul,
.manual-content ol {
  margin: 0.75rem 0 1rem 1.5rem;
  color: var(--text-secondary);
}

.manual-content li {
  margin-bottom: 0.4rem;
}

.manual-content strong {
  color: var(--text-primary);
}

.manual-content code {
  background: rgba(255, 107, 43, 0.1);
  color: var(--orange-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
}

.manual-content pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border-subtle);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}

.manual-content blockquote {
  border-left: 3px solid var(--orange);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.manual-cover {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 2rem;
}

/* Diagnostics */
.diagnostic-item {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  border-left: 4px solid;
}

.diagnostic-item.critical {
  background: rgba(239, 68, 68, 0.08);
  border-color: #ef4444;
}

.diagnostic-item.warning {
  background: rgba(255, 107, 43, 0.08);
  border-color: var(--orange);
}

.diagnostic-item.info {
  background: rgba(96, 165, 250, 0.08);
  border-color: #60a5fa;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.w-full { width: 100%; }

/* Mobile hamburger button */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-orange);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 99;
}

/* Login page — hide sidebar completely */
body.is-login #sidebar-container,
body.is-login .mobile-menu-btn {
  display: none !important;
}
body.is-login .main-content {
  margin-left: 0 !important;
  padding: 0 !important;
}

/* ========== RESPONSIVE ========== */

/* Large tablets */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .main-content {
    padding: 1.5rem;
  }
}

/* Tablets */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
  }
  .main-content {
    margin-left: 240px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile landscape / small tablet */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }

  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 150;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 4.5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .card {
    padding: 1.25rem;
    border-radius: 12px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  .flex-between {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .table th,
  .table td {
    padding: 0.625rem 0.75rem;
    font-size: 0.8rem;
  }

  .modal {
    padding: 1.25rem;
    margin: 0.5rem;
    max-height: 95vh;
    border-radius: 12px;
  }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }

  .top-bar {
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Grid forms: single column on mobile */
  .modal [style*="grid-template-columns"] {
    display: block !important;
  }
  .modal [style*="grid-template-columns"] .form-group {
    margin-bottom: 1.25rem;
  }
}

/* Mobile portrait */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    padding: 10px 18px;
    font-size: 0.9rem;
  }

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

  .table-container {
    margin: 0 -1.25rem;
    border-radius: 0;
  }

  .card {
    border-radius: 10px;
    padding: 1rem;
  }

  .modal {
    margin: 0;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 92vh;
    width: 100%;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }

  .stat-value { font-size: 1.35rem; }

  .sidebar-logo h1 { font-size: 1.1rem; }

  .number-large { font-size: 2rem; }
}

/* Extra small (320px) */
@media (max-width: 360px) {
  .main-content {
    padding: 0.75rem;
    padding-top: 4rem;
  }

  .btn {
    padding: 9px 14px;
    font-size: 0.85rem;
  }

  .stats-grid {
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.875rem;
  }
}

/* AI chat bubbles (dashboard) */
.ai-msg {
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border-subtle);
}
.ai-msg-user {
  align-self: flex-end;
  background: rgba(255, 107, 43, 0.15);
  border: 1px solid var(--glass-border);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 107, 43, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 107, 43, 0.5);
}
