/* =========================================
   Installment System UI — Professional Minimalist Edition
   Clean • Modern • Striped Tables • Status Badges
   Full Dark/Light Themes
========================================= */

/* ---------- Root Variables (Light Default) ---------- */
:root {
  --primary: #1e90ff;
  --primary-dark: #1a76d2;

  --bg: #f5f7fa;
  --bg-soft: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;

  --border: #e5e7eb;
  --shadow: 0 4px 14px rgba(0,0,0,0.08);

  /* Dark */
  --dark-bg: #0f172a;
  --dark-bg-soft: #1e293b;
  --dark-text: #e2e8f0;
  --dark-muted: #94a3b8;
  --dark-border: #334155;
  --dark-shadow: 0 6px 18px rgba(0,0,0,0.6);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --transition: 0.22s ease-out;
}

/* ---------- Light mode ---------- */
body {
  margin: 0;
  font-family: Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: var(--transition);
}

/* ---------- Dark Mode ---------- */
body.dark {
  background: var(--dark-bg);
  color: var(--dark-text);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb {
  background: #9ca3af;
  border-radius: 999px;
}

/* ---------- App Wrapper ---------- */
.app-wrapper {
  min-height: 100vh;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- Layout ---------- */
.main-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 210px 1fr;  /* FULL sidebar */
  gap: 16px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

body.dark .topbar {
  background: var(--dark-bg-soft);
  border-color: var(--dark-border);
  box-shadow: var(--dark-shadow);
}

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

.logo-dot {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--primary);
  box-shadow: 0 0 12px rgba(30,144,255,0.6);
}

.logo-title { font-size: 16px; font-weight: 600; }
.logo-sub { font-size: 11px; color: var(--text-muted); }

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

/* ---------- Sidebar (Icons + Labels) ---------- */
.sidebar {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 10px;
  box-shadow: var(--shadow);
}

body.dark .sidebar {
  background: var(--dark-bg-soft);
  border-color: var(--dark-border);
  box-shadow: var(--dark-shadow);
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: var(--transition);
}

.sidebar nav a i {
  font-size: 18px;
  width: 22px;
  text-align: center;
}

.sidebar nav a:hover {
  background: rgba(30,144,255,0.12);
  color: var(--primary);
}

.sidebar nav a.active {
  background: var(--primary);
  color: #fff !important;
  box-shadow: 0 4px 16px rgba(30,144,255,0.35);
}

/* ---------- Content Area ---------- */
.content {
  padding: 18px;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
}

.page-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

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

/* ---------- Cards ---------- */
.card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 18px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

body.dark .card {
  background: var(--dark-bg-soft);
  border-color: var(--dark-border);
}

.card:hover {
  transform: translateY(-2px);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px,1fr));
  gap: 14px;
  margin-bottom: 20px;
}

/* ---------- Buttons ---------- */
.btn {
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
}

.btn-ghost:hover {
  background: rgba(148,163,184,0.18);
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  gap: 5px;
}

.btn-sm i {
  font-size: 12px;
}

.w-full { width: 100%; }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

body.dark .card-header {
  border-bottom-color: var(--dark-border);
}

.card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

/* ---------- Inputs ---------- */
label {
  margin-top: 10px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 14px;
  color: var(--text);
  transition: var(--transition);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(30,144,255,0.25);
  outline: none;
}

/* ---------- Tables (Striped + Hover) ---------- */
.table-wrapper {
  max-height: 360px;
  overflow-y: auto;
  margin-top: 10px;
}

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

.table th {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 10px;
  position: sticky;
  top: 0;
}

body.dark .table th {
  background: var(--dark-bg-soft);
}

.table tr:nth-child(even) {
  background: rgba(0,0,0,0.035);
}

body.dark .table tr:nth-child(even) {
  background: rgba(255,255,255,0.04);
}

.table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.table tr:hover td {
  background: rgba(30,144,255,0.08);
}

/* ---------- Status Badges ---------- */
.badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}

.badge-success { background:#10b981; color:#fff; }
.badge-warning { background:#f59e0b; color:#fff; }
.badge-danger  { background:#ef4444; color:#fff; }

/* ---------- Search Row ---------- */
.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  margin-top: 4px;
}

.search-row input {
  border: none;
  background: transparent;
  padding: 0;
}

/* ---------- Guest (login) layout ---------- */
body.auth-guest .main-layout {
  grid-template-columns: 1fr;
  min-height: calc(100vh - 88px);
  align-items: stretch;
}

body.auth-guest .content {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}

body.auth-guest #view-login {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: min(640px, calc(100vh - 100px));
}

/* ---------- Premium login page ---------- */
.login-page {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.95fr);
  gap: 0;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  min-height: min(560px, calc(100vh - 120px));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 24px 80px rgba(15, 23, 42, 0.12);
}

body.dark .login-page {
  box-shadow:
    0 0 0 1px rgba(148, 163, 184, 0.12),
    0 24px 80px rgba(0, 0, 0, 0.45);
}

.login-brand {
  position: relative;
  padding: clamp(28px, 5vw, 48px);
  background:
    radial-gradient(120% 80% at 20% 0%, rgba(30, 144, 255, 0.35) 0%, transparent 55%),
    radial-gradient(90% 60% at 100% 100%, rgba(99, 102, 241, 0.25) 0%, transparent 50%),
    linear-gradient(155deg, #0f172a 0%, #1e293b 45%, #0f172a 100%);
  color: #e2e8f0;
  display: flex;
  align-items: center;
}

.login-brand-glow {
  position: absolute;
  inset: -40% -20%;
  background: radial-gradient(circle at 30% 40%, rgba(56, 189, 248, 0.15), transparent 50%);
  pointer-events: none;
}

.login-brand-inner {
  position: relative;
  z-index: 1;
}

.login-brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #7dd3fc;
  margin-bottom: 20px;
}

.login-brand-eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #94a3b8;
}

.login-brand-title {
  margin: 0 0 14px;
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.login-brand-desc {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.6;
  color: #94a3b8;
  max-width: 36ch;
}

.login-brand-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  color: #cbd5e1;
}

.login-brand-features i {
  color: #38bdf8;
  margin-right: 10px;
  font-size: 12px;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 4vw, 40px);
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
}

body.dark .login-panel {
  background: var(--dark-bg-soft);
  border-left-color: var(--dark-border);
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card-header {
  margin-bottom: 26px;
}

.login-card-title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card-sub {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

body.dark .login-card-sub {
  color: var(--dark-muted);
}

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

.login-form .field-group label {
  display: block;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

body.dark .login-form .field-group label {
  color: var(--dark-muted);
}

.input-affix {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  transition: var(--transition);
}

body.dark .input-affix {
  background: var(--dark-bg);
  border-color: var(--dark-border);
}

.input-affix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.2);
}

.input-affix i {
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
}

body.dark .input-affix i {
  color: var(--dark-muted);
}

.input-affix-password input {
  flex: 1;
  min-width: 0;
}

.input-affix-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0 -6px 0 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

body.dark .input-affix-toggle {
  color: var(--dark-muted);
}

.input-affix-toggle:hover {
  color: var(--primary);
  background: rgba(30, 144, 255, 0.1);
}

.input-affix-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.input-affix-toggle i {
  font-size: 15px;
  pointer-events: none;
}

.input-affix input {
  border: none;
  background: transparent;
  padding: 12px 0;
  box-shadow: none;
}

.input-affix input:focus {
  box-shadow: none;
}

.login-notify-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 8px 0 20px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(30, 144, 255, 0.04);
  cursor: pointer;
  font-size: 13px;
}

body.dark .login-notify-row {
  border-color: var(--dark-border);
  background: rgba(56, 189, 248, 0.06);
}

.login-notify-checkbox {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.login-notify-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.login-notify-title {
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

body.dark .login-notify-title {
  color: var(--dark-text);
}

.login-notify-title i {
  color: var(--primary);
}

.login-notify-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

body.dark .login-notify-hint {
  color: var(--dark-muted);
}

.btn-login {
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  justify-content: center;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(30, 144, 255, 0.35);
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(30, 144, 255, 0.4);
}

.btn-login:disabled {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-login i {
  font-size: 14px;
  opacity: 0.9;
}

.login-card-foot {
  margin: 22px 0 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

body.dark .login-card-foot {
  color: var(--dark-muted);
}

/* SweetAlert toast polish */
.swal2-toast.ims-toast-theme {
  border-radius: 12px !important;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15) !important;
}

body.dark .swal2-toast.ims-toast-theme {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5) !important;
}

@media (max-width: 860px) {
  .login-page {
    grid-template-columns: 1fr;
    max-width: 480px;
  }

  .login-brand {
    min-height: 200px;
    padding: 28px 24px;
  }

  .login-brand-title {
    font-size: 1.35rem;
  }

  .login-panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  body.dark .login-panel {
    border-top-color: var(--dark-border);
  }
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 100%;
    padding: 12px 18px;
  }
  .sidebar nav {
    flex-direction: row;
    justify-content: space-around;
  }
}

@media (max-width: 600px) {
  .app-wrapper { padding: 10px; }
  .content { padding: 10px; }
}
