/* ============================================================
   CloudPOS — Global Application Styles
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --primary: #0d6efd;
  --sidebar-bg: #1a1f2e;
  --sidebar-text: #c8d0e0;
  --sidebar-hover: rgba(255,255,255,.08);
  --sidebar-active: rgba(13,110,253,.25);
  --card-shadow: 0 1px 4px rgba(0,0,0,.06);
  --transition: .18s ease;
}

/* ── Base ───────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: .9rem;
  background: #f4f6fb;
  color: #212529;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0; left: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  overflow-x: hidden;
}

.sidebar.collapsed { width: 60px; }

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1rem;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.07);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand .brand-text { transition: opacity var(--transition); }
.sidebar.collapsed .brand-text { opacity: 0; width: 0; }

.sidebar-nav {
  flex: 1;
  padding: .5rem 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.nav-section {
  padding: .5rem 1rem .25rem;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-section { opacity: 0; height: 0; padding: 0; margin: 0; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem 1rem;
  color: var(--sidebar-text);
  white-space: nowrap;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  font-size: .875rem;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  border-right: 3px solid var(--primary);
}

.sidebar-link .nav-icon {
  width: 20px;
  text-align: center;
  font-size: .95rem;
  flex-shrink: 0;
  color: rgba(255,255,255,.55);
}

.sidebar-link.active .nav-icon,
.sidebar-link:hover .nav-icon { color: #fff; }

.sidebar-link .nav-label { transition: opacity var(--transition); }
.sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  position: fixed;
  top: 0; right: 0;
  left: var(--sidebar-width);
  z-index: 1030;
  gap: .75rem;
  transition: left var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.sidebar.collapsed ~ .main-content .topbar,
.sidebar.collapsed ~ * .topbar { left: 60px; }

.topbar .sidebar-toggle {
  background: none;
  border: none;
  color: #6c757d;
  font-size: 1.1rem;
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: .375rem;
  line-height: 1;
}
.topbar .sidebar-toggle:hover { background: #f0f4f8; color: #212529; }

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding-top: var(--topbar-height);
  transition: margin-left var(--transition);
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--sidebar-width));
}

.sidebar.collapsed ~ .main-content {
  margin-left: 60px;
  width: calc(100% - 60px);
}

.content-body { padding: 1.5rem; flex: 1; }

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  margin-bottom: 1.5rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid #e9ecef;
}

.page-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: #1a1f2e;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  border: 1px solid #e9ecef;
  border-radius: .625rem;
  box-shadow: var(--card-shadow);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  border-radius: .625rem .625rem 0 0 !important;
  font-size: .9rem;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table { font-size: .875rem; }
.table th {
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6c757d;
  background: #f8f9fa;
  white-space: nowrap;
}
.table-hover tbody tr:hover { background: #f0f4f8; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn { font-size: .875rem; font-weight: 500; border-radius: .5rem; }
.btn-sm { font-size: .8rem; padding: .3rem .65rem; }
.btn-lg { font-size: .95rem; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { font-weight: 600; letter-spacing: .02em; border-radius: .375rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: .5rem;
  font-size: .875rem;
  border-color: #dee2e6;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(13,110,253,.15);
}
.form-label { font-size: .875rem; }

/* ── Nav Tabs ───────────────────────────────────────────────── */
.nav-tabs .nav-link {
  font-size: .875rem;
  font-weight: 500;
  color: #6c757d;
  border-radius: .5rem .5rem 0 0;
}
.nav-tabs .nav-link.active { color: var(--primary); font-weight: 600; }

/* ── KPI Cards ──────────────────────────────────────────────── */
.kpi-card { border-left: 4px solid var(--primary); }
.kpi-card .kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.kpi-card .kpi-label { font-size: .75rem; color: #6c757d; text-transform: uppercase; letter-spacing: .05em; }

/* ── Alerts / Flash ─────────────────────────────────────────── */
.flash-message {
  position: fixed;
  top: calc(var(--topbar-height) + .75rem);
  right: 1rem;
  z-index: 2000;
  min-width: 280px;
  max-width: 420px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  border-radius: .5rem;
  animation: slideIn .2s ease;
}

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

/* ── Dark Mode ──────────────────────────────────────────────── */
body.dark-mode {
  background: #0f1117;
  color: #e2e8f0;
}

body.dark-mode .topbar,
body.dark-mode .card,
body.dark-mode .card-header,
body.dark-mode .modal-content,
body.dark-mode .dropdown-menu {
  background: #1a1f2e;
  border-color: #2d3446;
  color: #e2e8f0;
}

body.dark-mode .table { color: #e2e8f0; }
body.dark-mode .table th { background: #1e2435; color: #9aa5b4; }
body.dark-mode .table-hover tbody tr:hover { background: #242b3a; }
body.dark-mode .form-control,
body.dark-mode .form-select {
  background: #242b3a;
  border-color: #2d3446;
  color: #e2e8f0;
}
body.dark-mode .text-muted { color: #8898a8 !important; }
body.dark-mode .page-header { border-color: #2d3446; }
body.dark-mode .page-header h1 { color: #e2e8f0; }
body.dark-mode .nav-tabs .nav-link { color: #8898a8; }
body.dark-mode .nav-tabs { border-color: #2d3446; }
body.dark-mode .nav-tabs .nav-link.active { color: #60a5fa; border-color: #2d3446 #2d3446 #1a1f2e; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content {
    margin-left: 0;
    width: 100%;
  }
  .topbar { left: 0; }
  .content-body { padding: 1rem; }
}

/* ── Print ──────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin: 0; padding: 0; width: 100%; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ── Utilities ──────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.font-monospace { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.min-w-0 { min-width: 0; }
