/* ============================================================
   TCRM Global Styles — Tax Consultancy ERP
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #e0e7ff;
  --secondary:     #0ea5e9;
  --accent:        #f59e0b;
  --success:       #22c55e;
  --danger:        #ef4444;
  --warning:       #f97316;
  --info:          #06b6d4;

  /* Backgrounds */
  --bg-base:       #0f1117;
  --bg-surface:    #1a1d27;
  --bg-card:       #22263a;
  --bg-card-hover: #2a2f45;
  --bg-glass:      rgba(255,255,255,0.04);

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;

  /* Borders */
  --border:         rgba(255,255,255,0.08);
  --border-active:  rgba(99,102,241,0.5);

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 10px 40px rgba(0,0,0,0.5);
  --shadow-glow:0 0 30px rgba(99,102,241,0.25);

  /* Radii */
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  /* Sidebar */
  --sidebar-w:  260px;
  --topbar-h:   64px;

  /* Transitions */
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Light Theme ---------- */
[data-theme="light"] {
  --bg-base:       #f0f2f5;
  --bg-surface:    #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-glass:      rgba(0,0,0,0.03);

  --text-primary:   #1e293b;
  --text-secondary: #475569;
  --text-muted:     #64748b;

  --border:         rgba(0,0,0,0.08);
  --border-active:  rgba(99,102,241,0.4);

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  
  --shadow-glow:0 0 30px rgba(99,102,241,0.15);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; display: block; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: var(--bg-surface); }
::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ============================================================
   LAYOUT
   ============================================================ */

#app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition), width var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar.collapsed { width: 72px; }
#sidebar.collapsed .nav-label,
#sidebar.collapsed .sidebar-brand-text,
#sidebar.collapsed .nav-section-label { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.sidebar-brand img {
  max-width: 100%;
  object-fit: contain;
}

.sidebar-nav { padding: 12px 8px; flex: 1; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  white-space: nowrap;
  position: relative;
}

.nav-item:hover  { background: var(--bg-glass); color: var(--text-primary); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(99,102,241,0.2), transparent);
  color: var(--primary);
  border-left: 3px solid var(--primary);
  padding-left: 9px;
}

.nav-item .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}

.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info .name { font-size: 13px; font-weight: 600; truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.sidebar-user-info .role { font-size: 11px; color: var(--text-muted); }

/* ---------- Main Content ---------- */
#main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

#sidebar.collapsed ~ #main-content { margin-left: 72px; }

/* ---------- Topbar ---------- */
#topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

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

.icon-btn {
  width: 38px; height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg-card-hover); color: var(--primary); }

#page-content {
  padding: 24px;
  flex: 1;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-active); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title { font-size: 15px; font-weight: 700; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Stat cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-active); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-value { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat-delta { font-size: 11px; margin-top: 4px; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ============================================================
   FORMS & INPUTS
   ============================================================ */

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

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

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

.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--danger); margin-top: 4px; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 10px rgba(99,102,241,0.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-card-hover); }

.btn-success  { background: var(--success);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-warning  { background: var(--warning);  color: #fff; }
.btn-info     { background: var(--info);     color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-glass); color: var(--text-primary); }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-icon { padding: 10px; }
.btn-block { width: 100%; }

/* ============================================================
   TABLES
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-glass); }

/* ============================================================
   BADGES / STATUS PILLS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-primary  { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-success  { background: rgba(34,197,94,0.15);  color: #4ade80; }
.badge-danger   { background: rgba(239,68,68,0.15);  color: #f87171; }
.badge-warning  { background: rgba(249,115,22,0.15); color: #fb923c; }
.badge-info     { background: rgba(6,182,212,0.15);  color: #22d3ee; }
.badge-muted    { background: rgba(100,116,139,0.15);color: #94a3b8; }

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition);
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title  { font-size: 17px; font-weight: 700; }
.modal-close  { cursor: pointer; color: var(--text-muted); }
.modal-close:hover { color: var(--danger); }
.modal-footer { margin-top: 24px; display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   TOASTS
   ============================================================ */

#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info);    }

@keyframes slideInRight {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-left h1 {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-header-left p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ============================================================
   GRID LAYOUTS
   ============================================================ */

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ============================================================
   LOADING & EMPTY STATES
   ============================================================ */

.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 16px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-state p  { font-size: 13px; margin-top: 4px; }

/* ============================================================
   WORKFLOW KANBAN
   ============================================================ */

/* ============================================================
   WORKFLOW KANBAN
   ============================================================ */

.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 10px 0 40px;
  align-items: flex-start;
}

.kanban-col {
  width: 100%;
  min-width: 0; /* Allow grid to shrink it */
  background: var(--bg-surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: 100%;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 10;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kanban-col-count {
  margin-left: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
}

.kanban-cards-container {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kanban-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: transparent;
  transition: background var(--transition);
}

.kanban-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-md), 0 0 20px rgba(99,102,241,0.1);
  background: var(--bg-card-hover);
}

.kanban-card:active { transform: scale(0.98); }

.kanban-card-priority {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kanban-card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.4;
  color: var(--text-primary);
}

.kanban-card-client {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 11px;
}

.kanban-card-assignee {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  border: 2px solid var(--bg-card);
}

/* ============================================================
   MOBILE BOTTOM NAV
   ============================================================ */

#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 8px 0;
  z-index: 200;
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
  font-size: 10px;
  font-weight: 600;
}
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item svg { width: 22px; height: 22px; }

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

@media (max-width: 1024px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.mobile-open { transform: translateX(0); }
  #main-content { margin-left: 0 !important; }
  #bottom-nav { display: block; }
  #page-content { padding: 16px 16px 80px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3  { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px;  }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8   { margin-top: 8px;   }
.mt-16  { margin-top: 16px;  }
.mt-24  { margin-top: 24px;  }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.text-sm    { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-primary-color { color: var(--primary); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.pointer { cursor: pointer; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.highlight { color: var(--primary); font-weight: 600; }
