/* ============================================================
   TBM Client Portal - Design System
   Total Building Maintenance
   Apple-grade minimalist design
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Brand */
  --green-900: #14532d;
  --green-800: #166534;
  --green-700: #15803d;
  --green-600: #16a34a;
  --green-500: #22c55e;
  --green-400: #4ade80;
  --green-100: #dcfce7;
  --green-50:  #f0fdf4;

  /* Neutrals */
  --gray-950: #0a0a0a;
  --gray-900: #171717;
  --gray-800: #262626;
  --gray-700: #404040;
  --gray-600: #525252;
  --gray-500: #737373;
  --gray-400: #a3a3a3;
  --gray-300: #d4d4d4;
  --gray-200: #e5e5e5;
  --gray-100: #f5f5f5;
  --gray-50:  #fafafa;
  --white:    #ffffff;

  /* Status */
  --blue-500:   #3b82f6;
  --blue-100:   #dbeafe;
  --amber-500:  #f59e0b;
  --amber-100:  #fef3c7;
  --red-500:    #ef4444;
  --red-100:    #fee2e2;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --text-xs:  0.75rem;
  --text-sm:  0.875rem;
  --text-base: 1rem;
  --text-lg:  1.125rem;
  --text-xl:  1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Radii */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.08), 0 8px 10px rgba(0,0,0,0.04);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;

  /* Layout */
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --bottom-tab-h: 72px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--green-700);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* ---------- Utilities ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

.text-center { text-align: center; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--gray-500); }
.text-green { color: var(--green-700); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: var(--text-sm);
  border: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--green-800);
  color: var(--white);
}
.btn-primary:hover:not(:disabled) {
  background: var(--green-700);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-base);
  border-radius: var(--radius);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.btn-block {
  width: 100%;
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--gray-900);
  background: var(--white);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  outline: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--gray-400);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(22,101,52,0.1);
}

.form-input-lg {
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-lg);
  border-radius: var(--radius);
  text-align: center;
  letter-spacing: 2px;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--gray-900);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.6;
}

.badge-green {
  background: var(--green-100);
  color: var(--green-800);
}

.badge-blue {
  background: var(--blue-100);
  color: #1e40af;
}

.badge-amber {
  background: var(--amber-100);
  color: #92400e;
}

.badge-red {
  background: var(--red-100);
  color: #991b1b;
}

.badge-gray {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ---------- Stat Cards ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-top: var(--space-1);
  line-height: 1.2;
}

.stat-sub {
  font-size: var(--text-xs);
  color: var(--gray-400);
  margin-top: var(--space-1);
}

/* ---------- Login Page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--gray-50);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-10);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-2);
}

.login-logo-text {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--green-800);
  letter-spacing: -1px;
}

.login-heading {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--gray-500);
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-help {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--gray-400);
  margin-top: var(--space-6);
}
.login-help a {
  color: var(--green-700);
  font-weight: 500;
}

.login-error {
  background: var(--red-100);
  color: #991b1b;
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  display: none;
}
.login-error.visible {
  display: block;
}

/* ---------- App Layout ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar (desktop) */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform 0.3s var(--ease);
}

.sidebar-logo {
  padding: var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--gray-800);
}

.sidebar-logo-text {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--green-400);
}

.sidebar-logo-sub {
  font-size: var(--text-xs);
  color: var(--gray-400);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  color: var(--gray-400);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--duration) var(--ease);
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover {
  color: var(--white);
  background: var(--gray-800);
  text-decoration: none;
}
.nav-item.active {
  color: var(--white);
  background: var(--green-800);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--gray-800);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--green-800);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-200);
}
.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--gray-500);
}

/* Main content area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar-mobile-logo {
  display: none;
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--green-800);
}

.btn-menu {
  display: none;
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--gray-600);
}
.btn-menu svg { width: 24px; height: 24px; }

/* Page content */
.page-content {
  padding: var(--space-6);
  max-width: 1200px;
}

.page-greeting {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
}

.page-greeting-sub {
  font-size: var(--text-sm);
  color: var(--gray-500);
  margin-top: var(--space-1);
}

/* ---------- Dashboard Grids ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-top: var(--space-6);
}

.dash-grid .card.full-width {
  grid-column: 1 / -1;
}

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-3);
  border-radius: var(--radius);
  background: var(--gray-50);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--gray-700);
}
.quick-action:hover {
  background: var(--green-50);
  border-color: var(--green-100);
  text-decoration: none;
  color: var(--green-800);
}

.quick-action-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--green-100);
  color: var(--green-800);
  display: flex;
  align-items: center;
  justify-content: center;
}
.quick-action-icon svg { width: 22px; height: 22px; }

.quick-action-label {
  font-size: var(--text-xs);
  font-weight: 500;
  text-align: center;
}

/* ---------- Schedule List ---------- */
.schedule-list {
  list-style: none;
}

.schedule-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--gray-100);
}
.schedule-item:last-child { border-bottom: none; }

.schedule-date-box {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--green-50);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.schedule-date-month {
  font-size: 10px;
  font-weight: 600;
  color: var(--green-700);
  text-transform: uppercase;
}

.schedule-date-day {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--green-900);
  line-height: 1;
}

.schedule-info { flex: 1; min-width: 0; }
.schedule-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-900);
}
.schedule-time {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin-top: 1px;
}

/* ---------- Invoice List ---------- */
.invoice-list {
  list-style: none;
}

.invoice-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--gray-100);
}
.invoice-item:last-child { border-bottom: none; }

.invoice-info { flex: 1; min-width: 0; }
.invoice-number {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-900);
}
.invoice-date {
  font-size: var(--text-xs);
  color: var(--gray-500);
}
.invoice-amount {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-900);
}

/* ---------- Schedule Page ---------- */
.month-selector {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.month-label {
  font-size: var(--text-lg);
  font-weight: 600;
  min-width: 180px;
  text-align: center;
}

.btn-arrow {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border: 1px solid var(--gray-200);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  color: var(--gray-600);
}
.btn-arrow:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}
.btn-arrow svg { width: 18px; height: 18px; }

.schedule-page-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-3);
  transition: box-shadow var(--duration) var(--ease);
}
.schedule-page-item:hover {
  box-shadow: var(--shadow-md);
}

.schedule-page-details { flex: 1; }
.schedule-page-type {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-900);
}
.schedule-page-meta {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin-top: 2px;
}

/* ---------- Invoice Page ---------- */
.invoice-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.invoice-page-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-3);
}

.invoice-page-info { flex: 1; }
.invoice-page-number {
  font-size: var(--text-sm);
  font-weight: 600;
}
.invoice-page-desc {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin-top: 2px;
}
.invoice-page-amount {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--gray-900);
}

/* ---------- Requests Page ---------- */
.request-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-3);
}

.request-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--gray-100);
  color: var(--gray-600);
}
.request-icon svg { width: 20px; height: 20px; }

.request-info { flex: 1; }
.request-subject {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-900);
}
.request-desc {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.request-meta {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-2);
}

/* ---------- Messages Page ---------- */
.messages-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - var(--space-12));
  max-height: 700px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.messages-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--gray-100);
  font-weight: 600;
}

.messages-thread {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.message-bubble {
  max-width: 75%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.5;
  position: relative;
}

.message-bubble.outgoing {
  align-self: flex-end;
  background: var(--green-800);
  color: var(--white);
  border-bottom-right-radius: var(--space-1);
}

.message-bubble.incoming {
  align-self: flex-start;
  background: var(--gray-100);
  color: var(--gray-900);
  border-bottom-left-radius: var(--space-1);
}

.message-time {
  font-size: 10px;
  margin-top: var(--space-1);
  opacity: 0.6;
}

.message-bubble.outgoing .message-time { text-align: right; }

.message-sender {
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--green-700);
}

.messages-input-bar {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--gray-100);
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
}

.messages-input-bar .form-input {
  flex: 1;
}

.messages-input-bar .btn-primary {
  height: 44px;
  width: 44px;
  padding: 0;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.messages-input-bar .btn-primary svg { width: 20px; height: 20px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform 0.2s var(--ease);
}
.modal-overlay.visible .modal {
  transform: translateY(0);
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--gray-100);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  transition: background var(--duration) var(--ease);
}
.modal-close:hover { background: var(--gray-200); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  min-width: 280px;
  pointer-events: auto;
  animation: toastIn 0.3s var(--ease);
  border-left: 4px solid var(--green-500);
}
.toast.error { border-left-color: var(--red-500); }
.toast.warning { border-left-color: var(--amber-500); }

.toast.removing {
  animation: toastOut 0.3s var(--ease) forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ---------- Loading / Skeleton ---------- */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 14px;
  margin-bottom: var(--space-3);
  width: 100%;
}
.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-25 { width: 25%; }

.skeleton-box {
  height: 48px;
  margin-bottom: var(--space-3);
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--gray-400);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: var(--text-sm);
  max-width: 300px;
  margin: 0 auto;
}

/* ---------- Bottom Tabs (Mobile) ---------- */
.bottom-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-tab-h);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-tabs-inner {
  display: flex;
  height: 100%;
}

.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--gray-400);
  font-size: 10px;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}
.bottom-tab:hover { text-decoration: none; }
.bottom-tab svg { width: 22px; height: 22px; }
.bottom-tab.active {
  color: var(--green-700);
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 35;
  }
  .sidebar.open ~ .sidebar-backdrop,
  .sidebar-backdrop.visible {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .btn-menu { display: flex; }
  .topbar-mobile-logo { display: block; }

  .bottom-tabs { display: block; }

  .page-content {
    padding-bottom: calc(var(--bottom-tab-h) + var(--space-6));
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .page-content {
    padding: var(--space-4);
    padding-bottom: calc(var(--bottom-tab-h) + var(--space-4));
  }

  .login-card {
    padding: var(--space-8) var(--space-6);
  }

  .stat-card {
    padding: var(--space-4);
  }

  .stat-value {
    font-size: var(--text-xl);
  }

  .message-bubble {
    max-width: 85%;
  }

  .invoice-summary {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .bottom-tabs, .topbar { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none; border: 1px solid var(--gray-200); }
}
