/*
  app.css - Premium SaaS UI layer (non-breaking)
  Design tokens + auth page components.
*/

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;

  --bg-0: #0b1020;
  --bg-1: #0f172a;
  --bg-2: #111827;

  --surface: rgba(255,255,255,0.92);
  --surface-2: rgba(255,255,255,0.75);
  --border: rgba(15, 23, 42, 0.10);

  --text: #0f172a;
  --muted: #64748b;

  --brand: #6366f1;
  --brand-2: #7c3aed;
  --danger: #ef4444;
  --success: #22c55e;

  --radius: 18px;
  --radius-sm: 12px;

  --shadow-lg: 0 30px 80px rgba(2, 6, 23, 0.28);
  --shadow-md: 0 18px 45px rgba(2, 6, 23, 0.18);

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;

  /* App shell (light) */
  --app-bg: #f6f7fb;
  --app-surface: #ffffff;
  --app-surface-2: #fbfcff;
  --app-border: rgba(15, 23, 42, 0.10);
  --app-shadow: 0 10px 30px rgba(2, 6, 23, 0.08);
  --app-shadow-sm: 0 6px 18px rgba(2, 6, 23, 0.08);

  --sidebar-bg: linear-gradient(180deg, #0b1220 0%, #0b1220 30%, #0a1020 100%);
  --sidebar-border: rgba(255,255,255,0.10);
  --sidebar-text: rgba(255,255,255,0.86);
  --sidebar-muted: rgba(255,255,255,0.60);
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active: rgba(99,102,241,0.18);

  --topbar-bg: rgba(255,255,255,0.86);
  --topbar-border: rgba(15,23,42,0.08);
}

html, body {
  font-family: var(--font-sans);
}

body {
  background: var(--app-bg);
}

/* --------------------
   Auth (Login)
--------------------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  background:
    radial-gradient(1000px 600px at 10% 10%, rgba(99,102,241,0.30), transparent 60%),
    radial-gradient(900px 500px at 90% 20%, rgba(124,58,237,0.30), transparent 60%),
    linear-gradient(135deg, #0b1020 0%, #0f172a 55%, #0b1020 100%);
  color: #e5e7eb;
}

.auth-left {
  flex: 1;
  display: none;
  padding: clamp(24px, 4vw, 56px);
}

.auth-left .auth-brand {
  max-width: 520px;
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  font-weight: 600;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
}

.auth-title {
  margin-top: 18px;
  font-size: clamp(28px, 3vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.auth-subtitle {
  margin-top: 12px;
  color: rgba(255,255,255,0.75);
  font-size: 15px;
  line-height: 1.6;
}

.auth-feature {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  color: rgba(255,255,255,0.78);
  font-size: 14px;
}

.auth-feature i {
  color: rgba(255,255,255,0.9);
}

.auth-right {
  width: min(520px, 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.auth-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  overflow: hidden;
}

.auth-card-inner {
  padding: 26px;
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-logo img {
  max-height: 44px;
  max-width: 160px;
  object-fit: contain;
}

.auth-company {
  display: grid;
  line-height: 1.2;
}

.auth-company strong {
  font-size: 16px;
}

.auth-company span {
  font-size: 12px;
  color: var(--muted);
}

.auth-body {
  margin-top: 18px;
}

.auth-alert {
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.22);
  color: #991b1b;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.auth-alert.is-animate {
  animation: shakeX 300ms ease;
}

.form-grid {
  margin-top: 16px;
  display: grid;
  gap: 14px;
}

.float-field {
  position: relative;
}

.float-field input {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 14px;
  padding: 14px 44px 14px 44px;
  font-size: 14px;
  background: rgba(255,255,255,0.95);
  outline: none;
  transition: box-shadow 140ms ease, border-color 140ms ease;
}

.float-field input:focus {
  border-color: rgba(99, 102, 241, 0.55);
  box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.14);
}

.float-field label {
  position: absolute;
  left: 44px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(15, 23, 42, 0.55);
  font-size: 13px;
  pointer-events: none;
  transition: all 120ms ease;
  background: transparent;
}

.float-field input::placeholder { color: transparent; }

.float-field input:focus + label,
.float-field input:not(:placeholder-shown) + label {
  top: 7px;
  transform: translateY(0);
  font-size: 11px;
  color: rgba(99, 102, 241, 0.95);
}

.field-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(15, 23, 42, 0.45);
}

.field-action {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: rgba(15, 23, 42, 0.55);
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.field-action:hover {
  background: rgba(15, 23, 42, 0.06);
  color: rgba(15, 23, 42, 0.75);
}

.auth-actions {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.auth-actions a {
  color: rgba(99, 102, 241, 0.95);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}

.auth-actions a:hover { text-decoration: underline; }

.auth-submit {
  margin-top: 16px;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: 0 16px 40px rgba(99,102,241,0.28);
  transition: transform 120ms ease, filter 120ms ease;
}

.auth-submit:hover { filter: brightness(1.02); transform: translateY(-1px); }
.auth-submit:active { transform: translateY(0); }

.auth-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(15, 23, 42, 0.10);
  display: grid;
  gap: 10px;
}

.auth-footer small {
  color: rgba(15, 23, 42, 0.55);
}

@media (min-width: 992px) {
  .auth-left { display: flex; }
  .auth-right { width: 540px; }
}

/* --------------------
   App Shell: Sidebar collapse (desktop)
--------------------- */

.sidebar-collapsed .sidebar {
  width: 78px;
}

.sidebar-collapsed .main-content {
  margin-left: 78px;
}

.sidebar-collapsed .sidebar .nav-link {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
  text-align: center;
}

.sidebar-collapsed .sidebar .nav-link i {
  margin-right: 0 !important;
}

.sidebar-collapsed .sidebar .nav-link:hover,
.sidebar-collapsed .sidebar .nav-link.active {
  transform: none;
}

.sidebar-collapsed .sidebar-header small {
  display: none;
}

/* --------------------
   App Shell: layout + sidebar + topbar
--------------------- */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(2px);
  z-index: 998;
}

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

.sidebar {
  height: 100vh;
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  z-index: 1000;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  transition: width 180ms ease, transform 180ms ease;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 18px 18px 14px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-header h4 {
  font-size: 16px;
  letter-spacing: -0.01em;
}

.sidebar-menu {
  flex: 1;
  overflow: auto;
  padding: 10px 12px 18px 12px;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 4px 0;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.sidebar .nav-link i {
  width: 20px;
  text-align: center;
  color: rgba(255,255,255,0.78);
}

.sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  transform: translateX(3px);
  color: #fff;
}

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

.sidebar .nav-link.active i {
  color: rgba(255,255,255,0.95);
}

.sidebar hr {
  border-color: rgba(255,255,255,0.12);
}

.main-content {
  margin-left: 260px;
  min-height: 100vh;
  background: var(--app-bg);
  transition: margin-left 180ms ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 999;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  backdrop-filter: blur(10px);
  padding: 12px 18px;
}

.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 12px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
}

.topbar-icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: rgba(15, 23, 42, 0.72);
  position: relative;
  transition: background 150ms ease, transform 150ms ease;
}

.topbar-icon:hover {
  background: rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border: 2px solid #fff;
}

.online-status {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 6px rgba(34,197,94,0.14);
  display: inline-block;
}

@media (max-width: 768px) {
  .mobile-menu-toggle { display: inline-flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* --------------------
   Dashboard widgets
--------------------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  color: #0f172a;
}

.page-subtitle {
  margin: 6px 0 0 0;
  color: rgba(15, 23, 42, 0.60);
  font-size: 13px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.kpi-card {
  grid-column: span 3;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 16px;
  box-shadow: var(--app-shadow-sm);
  padding: 14px 14px;
  overflow: hidden;
}

.kpi-card.is-gradient {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
}

.kpi-card.is-success { background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%); color: #fff; border: none; }
.kpi-card.is-danger { background: linear-gradient(135deg, #dc2626 0%, #fb7185 100%); color: #fff; border: none; }
.kpi-card.is-info { background: linear-gradient(135deg, #0284c7 0%, #6366f1 100%); color: #fff; border: none; }
.kpi-card.is-warning { background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%); color: #fff; border: none; }

.kpi-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.kpi-label {
  font-size: 12px;
  opacity: 0.9;
  margin: 0;
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.16);
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.panel {
  grid-column: span 6;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 16px;
  box-shadow: var(--app-shadow-sm);
  overflow: hidden;
}

.panel-head {
  padding: 14px 14px 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.panel-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  font-size: 14px;
  color: #0f172a;
}

.panel-body {
  padding: 14px;
}

.panel.span-12 { grid-column: span 12; }
.panel.span-8 { grid-column: span 8; }
.panel.span-4 { grid-column: span 4; }

@media (max-width: 1200px) {
  .kpi-card { grid-column: span 6; }
  .panel { grid-column: span 12; }
  .panel.span-8 { grid-column: span 12; }
  .panel.span-4 { grid-column: span 12; }
}

@media (max-width: 576px) {
  .kpi-card { grid-column: span 12; }
}
