/* ============================================================
   Maison Chic ERP — Design System
   Paleta: Verde Esmeralda + Blanco — Elegante y Femenino
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Tokens ── */
:root {
  --emerald-900: #0d3d2e;
  --emerald-800: #1a5c45;
  --emerald-700: #1f7055;
  --emerald-600: #2a9068;
  --emerald-500: #34a87c;
  --emerald-400: #4dc494;
  --emerald-300: #7dd4ae;
  --emerald-100: #d4f0e6;
  --emerald-50:  #eaf8f2;

  --gold-400: #c9a84c;
  --gold-300: #d4b96a;
  --gold-100: #f5e9c8;

  --white:      #ffffff;
  --off-white:  #f8faf9;
  --gray-50:    #f0f4f2;
  --gray-100:   #e2ebe6;
  --gray-200:   #c5d5cc;
  --gray-400:   #7a9e8e;
  --gray-600:   #3d6354;
  --gray-800:   #1e3a2f;
  --dark:       #0a2d20;

  --sidebar-w: 260px;
  --topbar-h:  64px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 3px rgba(10,45,32,.08), 0 1px 2px rgba(10,45,32,.06);
  --shadow-md: 0 4px 16px rgba(10,45,32,.10), 0 2px 6px rgba(10,45,32,.07);
  --shadow-lg: 0 10px 40px rgba(10,45,32,.14), 0 4px 12px rgba(10,45,32,.08);
  --shadow-glow: 0 0 24px rgba(52,168,124,.20);

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui:      'Inter', system-ui, sans-serif;

  --transition: 200ms cubic-bezier(.4,0,.2,1);
  --transition-slow: 400ms cubic-bezier(.4,0,.2,1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--off-white);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ── Layout ── */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--emerald-900) 0%, var(--dark) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition-slow);
  overflow: hidden;
}
.sidebar::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(52,168,124,.18) 0%, transparent 70%);
  pointer-events: none;
}
.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo .brand {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  color: var(--white);
  letter-spacing: .03em;
  line-height: 1.1;
}
.sidebar-logo .brand span {
  color: var(--emerald-400);
}
.sidebar-logo .tagline {
  font-size: .72rem;
  color: var(--gray-400);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-top: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gray-400);
  padding: 16px 24px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  color: rgba(255,255,255,.65);
  font-size: .875rem;
  font-weight: 400;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  color: var(--white);
  background: rgba(255,255,255,.05);
}
.nav-item.active {
  color: var(--white);
  background: linear-gradient(90deg, rgba(52,168,124,.20) 0%, transparent 100%);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--emerald-400);
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.nav-badge {
  margin-left: auto;
  background: var(--emerald-600);
  color: var(--white);
  font-size: .65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  line-height: 1.4;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--emerald-600), var(--emerald-400));
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
}
.user-info .user-name { font-size: .8rem; font-weight: 600; color: var(--white); }
.user-info .user-role { font-size: .7rem; color: var(--gray-400); }

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

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--emerald-800);
}
.topbar-subtitle { font-size: .8rem; color: var(--gray-400); margin-top: 1px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-50);
  color: var(--gray-600);
  font-size: 1rem;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
  border: 1px solid var(--gray-100);
}
.topbar-btn:hover { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-200); }
.topbar-notif::after {
  content: '';
  position: absolute;
  top: 8px; right: 8px;
  width: 7px; height: 7px;
  background: var(--emerald-500);
  border-radius: 50%;
  border: 2px solid var(--white);
}
.online-status {
  display: flex; align-items: center; gap: 6px;
  font-size: .75rem; color: var(--gray-400);
  padding: 6px 12px;
  background: var(--gray-50);
  border-radius: 20px;
  border: 1px solid var(--gray-100);
}
.online-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--emerald-500);
  animation: pulse-dot 2s infinite;
}
.online-dot.offline { background: #e53e3e; animation: none; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .6; transform: scale(.85); }
}

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
  width: 100%;
}

/* ── Page Header ── */
.page-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  color: var(--emerald-900);
  line-height: 1.15;
}
.page-header p { font-size: .875rem; color: var(--gray-400); margin-top: 4px; }

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  cursor: default;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 0 var(--radius-md) 0 80px;
  opacity: .06;
  transition: opacity var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-card:hover::after { opacity: .1; }
.kpi-card.emerald::after { background: var(--emerald-500); }
.kpi-card.gold::after    { background: var(--gold-400); }
.kpi-card.teal::after    { background: #0e7490; }
.kpi-card.rose::after    { background: #be185d; }

.kpi-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 14px;
}
.kpi-card.emerald .kpi-icon { background: var(--emerald-50); color: var(--emerald-700); }
.kpi-card.gold    .kpi-icon { background: var(--gold-100);   color: #92650a; }
.kpi-card.teal    .kpi-icon { background: #e0f2fe;           color: #0e7490; }
.kpi-card.rose    .kpi-icon { background: #fce7f3;           color: #be185d; }

.kpi-label { font-size: .78rem; font-weight: 500; color: var(--gray-400); letter-spacing: .04em; text-transform: uppercase; }
.kpi-value { font-size: 1.85rem; font-weight: 700; color: var(--emerald-900); line-height: 1.1; margin: 6px 0 8px; }
.kpi-change { font-size: .78rem; display: flex; align-items: center; gap: 4px; }
.kpi-change.up   { color: var(--emerald-600); }
.kpi-change.down { color: #dc2626; }

/* ── Grid Layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.col-span-2 { grid-column: span 2; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--emerald-900);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .icon { color: var(--emerald-600); }
.card-body { padding: 20px 22px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  font-family: var(--font-ui);
}
.btn-primary {
  background: var(--emerald-700);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--emerald-600);
  box-shadow: 0 4px 12px rgba(26,92,69,.3);
  transform: translateY(-1px);
}
.btn-outline {
  background: transparent;
  color: var(--emerald-700);
  border: 1.5px solid var(--emerald-200);
}
.btn-outline:hover {
  background: var(--emerald-50);
  border-color: var(--emerald-400);
}
.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  padding: 9px 12px;
}
.btn-ghost:hover { background: var(--gray-50); color: var(--emerald-700); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}
tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--gray-50);
  color: var(--gray-800);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--emerald-50); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-success { background: var(--emerald-50);  color: var(--emerald-700); }
.badge-warning { background: #fef9c3;             color: #854d0e; }
.badge-danger  { background: #fef2f2;             color: #b91c1c; }
.badge-info    { background: #eff6ff;             color: #1d4ed8; }
.badge-neutral { background: var(--gray-50);      color: var(--gray-600); }

/* ── Form ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
  letter-spacing: .02em;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--gray-800);
  background: var(--white);
  transition: all var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(52,168,124,.12);
}
.form-control::placeholder { color: var(--gray-200); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Search ── */
.search-box {
  position: relative;
}
.search-box input {
  padding-left: 38px;
  background: var(--gray-50);
  border-color: var(--gray-100);
}
.search-box::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .85rem;
  pointer-events: none;
}

/* ── Progress Bar ── */
.progress { height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald-600), var(--emerald-400));
  border-radius: 3px;
  transition: width .6s ease;
}

/* ── Chart placeholder ── */
.chart-area {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 4px;
}
.chart-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--emerald-500), var(--emerald-700));
  transition: all var(--transition-slow);
  position: relative;
  min-width: 12px;
}
.chart-bar:hover { background: linear-gradient(180deg, var(--emerald-400), var(--emerald-600)); }
.chart-bar.secondary { background: linear-gradient(180deg, var(--emerald-200), var(--emerald-100)); }
.chart-labels {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding: 0 4px;
}
.chart-labels span {
  flex: 1;
  font-size: .65rem;
  color: var(--gray-400);
  text-align: center;
  min-width: 12px;
}

/* ── Tag / Chip ── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--emerald-50);
  color: var(--emerald-700);
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 500;
  border: 1px solid var(--emerald-100);
  margin: 2px;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--gray-600); margin-bottom: 8px; }
.empty-state p { font-size: .875rem; }

/* ── Toast / Notification ── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--emerald-500);
  min-width: 280px;
  max-width: 380px;
  animation: slideInRight .3s ease;
  font-size: .875rem;
}
.toast.error { border-left-color: #dc2626; }
.toast.warning { border-left-color: var(--gold-400); }
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,45,32,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--emerald-900);
}
.modal-body { padding: 22px 26px; }
.modal-footer {
  padding: 16px 26px 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--gray-50);
}

/* ── Sidebar overlay mobile ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ── PWA Install Banner ── */
#install-banner {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(135deg, var(--emerald-900), var(--emerald-800));
  color: var(--white);
  padding: 16px 24px;
  z-index: 300;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 -4px 20px rgba(10,45,32,.3);
}
#install-banner.show { display: flex; }
#install-banner .banner-text { font-size: .875rem; }
#install-banner .banner-title { font-weight: 600; margin-bottom: 2px; }
#install-banner .banner-sub { font-size: .78rem; opacity: .7; }
#install-banner .banner-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .col-span-2 { grid-column: span 1; }
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay { display: block; }
  .main { margin-left: 0; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Animations ── */
.fade-in {
  animation: fadeIn .3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Utility ── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-emerald { color: var(--emerald-700); }
.text-muted   { color: var(--gray-400); }
.text-sm      { font-size: .8rem; }
.fw-600       { font-weight: 600; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mb-8         { margin-bottom: 8px; }
.mb-16        { margin-bottom: 16px; }
.mb-20        { margin-bottom: 20px; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.w-full       { width: 100%; }
