/* ================================================================
   SiSurat Pramuka Medan - Main CSS
   Tema: Hijau Pramuka, Mobile-First
   ================================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* --- Variables --- */
:root {
  --primary:       #1a6b3a;
  --primary-dark:  #134f2b;
  --primary-light: #e8f5ee;
  --accent:        #f5a623;
  --accent-dark:   #d4891a;
  --danger:        #dc3545;
  --warning:       #ffc107;
  --success:       #28a745;
  --info:          #17a2b8;
  --text:          #1f2937;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --bg:            #f4f7f4;
  --white:         #ffffff;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.10);
  --shadow-md:     0 4px 12px rgba(0,0,0,.12);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.15);
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --font:          'Plus Jakarta Sans', sans-serif;
  --sidebar-w:     260px;
  --topbar-h:      60px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ================================================================
   LAYOUT UTAMA
   ================================================================ */
.app-wrapper { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .3s ease;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo img { width: 38px; height: 38px; border-radius: 50%; }
.sidebar-logo-text { font-size: .85rem; font-weight: 700; line-height: 1.2; }
.sidebar-logo-sub  { font-size: .7rem; opacity: .75; font-weight: 400; }

.sidebar-user {
  padding: 14px 20px;
  background: rgba(255,255,255,.07);
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: .8rem;
}
.sidebar-user-name   { font-weight: 600; font-size: .88rem; }
.sidebar-user-kwartir { opacity: .8; font-size: .75rem; margin-top: 2px; }
.sidebar-badge {
  display: inline-block; padding: 1px 8px;
  background: var(--accent); color: #fff;
  border-radius: 20px; font-size: .68rem; font-weight: 600;
  margin-top: 5px;
}

.sidebar-nav { flex: 1; padding: 10px 0; }
.sidebar-section-label {
  padding: 10px 20px 4px;
  font-size: .68rem; text-transform: uppercase;
  letter-spacing: .08em; opacity: .5; font-weight: 600;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.85);
  font-size: .87rem; font-weight: 500;
  transition: background .2s, color .2s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--accent);
  text-decoration: none;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .8rem; opacity: .75;
}

/* --- Main content --- */
.main-content {
  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(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 14px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 1rem; font-weight: 600; flex: 1; }
.topbar-menu-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 4px; color: var(--text);
}
.topbar-menu-btn svg { width: 22px; height: 22px; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }
.btn-topbar {
  padding: 6px 14px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: .82rem; font-weight: 600; cursor: pointer;
  font-family: var(--font);
  display: flex; align-items: center; gap: 5px;
  transition: background .2s;
}
.btn-topbar:hover { background: var(--primary-dark); }
.btn-topbar.secondary {
  background: var(--white); color: var(--text);
  border: 1px solid var(--border);
}
.btn-topbar.secondary:hover { background: var(--bg); }

/* --- Page content --- */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.card-title {
  font-size: .97rem; font-weight: 700; color: var(--primary-dark);
}
.card-body { padding: 20px; }

/* --- Stat Cards --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.green  { background: var(--primary-light); color: var(--primary); }
.stat-icon.amber  { background: #fff8e6; color: var(--accent-dark); }
.stat-icon.blue   { background: #e8f4fd; color: #1a6eb8; }
.stat-icon.red    { background: #fdecea; color: var(--danger); }
.stat-icon svg    { width: 22px; height: 22px; }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }

/* ================================================================
   TABLE
   ================================================================ */
.table-wrapper { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse;
  font-size: .87rem;
}
table.data-table th {
  background: var(--bg); text-align: left;
  padding: 10px 14px;
  font-weight: 600; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--bg); }

.nomor-surat-cell { font-weight: 700; color: var(--primary); font-family: monospace; font-size: .9rem; }
.badge {
  display: inline-block; padding: 2px 10px;
  border-radius: 20px; font-size: .72rem; font-weight: 600;
}
.badge-success  { background: #d4edda; color: #155724; }
.badge-warning  { background: #fff3cd; color: #856404; }
.badge-danger   { background: #f8d7da; color: #721c24; }
.badge-info     { background: #d1ecf1; color: #0c5460; }

/* ================================================================
   FORMS
   ================================================================ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; margin-bottom: 5px;
  font-size: .83rem; font-weight: 600; color: var(--text);
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control, .form-select {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .9rem;
  color: var(--text); background: var(--white);
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,107,58,.12);
}
textarea.form-control { resize: vertical; min-height: 90px; }

/* Nomor surat preview */
.nomor-preview {
  background: var(--primary-light);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  text-align: center;
  margin: 16px 0;
}
.nomor-preview-label { font-size: .75rem; color: var(--text-muted); margin-bottom: 4px; }
.nomor-preview-value {
  font-size: 1.5rem; font-weight: 700;
  color: var(--primary); font-family: monospace;
  letter-spacing: .04em;
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .87rem; font-weight: 600;
  cursor: pointer; border: none; transition: all .2s;
  text-decoration: none !important; white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline   { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-sm        { padding: 5px 12px; font-size: .8rem; }
.btn-icon      { padding: 7px; }
.btn svg       { width: 16px; height: 16px; flex-shrink: 0; }

/* ================================================================
   ALERTS
   ================================================================ */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .87rem; margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 8px;
  border-left: 4px solid;
}
.alert-success { background: #d4edda; color: #155724; border-color: var(--success); }
.alert-danger  { background: #f8d7da; color: #721c24; border-color: var(--danger); }
.alert-warning { background: #fff3cd; color: #856404; border-color: var(--warning); }
.alert-info    { background: #d1ecf1; color: #0c5460; border-color: var(--info); }

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center; margin-bottom: 24px;
}
.login-logo img { width: 64px; margin-bottom: 10px; }
.login-logo h1  { font-size: 1.3rem; font-weight: 700; color: var(--primary-dark); }
.login-logo p   { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
.login-box .form-control { padding: 11px 14px; }
.btn-login {
  width: 100%; padding: 12px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .95rem;
  font-weight: 700; cursor: pointer;
  margin-top: 8px; transition: background .2s;
}
.btn-login:hover { background: var(--primary-dark); }

/* ================================================================
   QR CODE
   ================================================================ */
.qr-container {
  text-align: center; padding: 16px;
}
.qr-img {
  width: 160px; height: 160px;
  border: 3px solid var(--border);
  border-radius: var(--radius-sm);
  image-rendering: pixelated;
}
.qr-label {
  font-size: .75rem; color: var(--text-muted);
  margin-top: 8px; display: block;
}

/* Detail surat (hasil scan) */
.surat-detail-card {
  max-width: 480px; margin: 0 auto;
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); overflow: hidden;
}
.surat-detail-header {
  background: var(--primary); color: #fff;
  padding: 18px 20px;
  display: flex; align-items: center; gap: 12px;
}
.surat-detail-header svg { width: 28px; height: 28px; flex-shrink: 0; }
.surat-detail-body { padding: 20px; }
.surat-detail-row { margin-bottom: 12px; }
.surat-detail-row label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 600; }
.surat-detail-row p { font-size: .92rem; color: var(--text); margin-top: 2px; font-weight: 500; }
.surat-detail-nomor { font-size: 1.3rem; font-weight: 800; color: var(--primary); font-family: monospace; }

/* ================================================================
   SEARCH & FILTER BAR
   ================================================================ */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  align-items: center; margin-bottom: 16px;
}
.filter-bar .form-control,
.filter-bar .form-select { max-width: 200px; }
.search-input-wrap { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.search-input-wrap input { padding-left: 36px; }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.search-icon svg { width: 16px; height: 16px; }

/* ================================================================
   PAGINATION
   ================================================================ */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; padding: 16px 0; }
.pagination a, .pagination span {
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: .83rem; font-weight: 500;
  border: 1px solid var(--border); color: var(--text);
}
.pagination a:hover { background: var(--bg); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ================================================================
   SCAN PAGE
   ================================================================ */
.scan-page { min-height: 100vh; background: var(--bg); padding: 20px; }
.scan-header {
  background: var(--primary); color: #fff;
  border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 20px;
  text-align: center;
}

/* ================================================================
   OVERLAY / MOBILE SIDEBAR
   ================================================================ */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 190;
}

/* ================================================================
   RESPONSIVE - Mobile
   ================================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.visible { display: block; }
  .main-content { margin-left: 0; }
  .topbar-menu-btn { display: flex; }
  .page-content { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-value { font-size: 1.4rem; }
  .filter-bar .form-control,
  .filter-bar .form-select { max-width: none; width: 100%; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  table.data-table { font-size: .8rem; }
  table.data-table th, table.data-table td { padding: 8px 10px; }
  .btn { padding: 8px 14px; font-size: .83rem; }
  .login-box { padding: 28px 20px; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .nomor-preview-value { font-size: 1.2rem; }
}

/* ================================================================
   PRINT
   ================================================================ */
@media print {
  .sidebar, .topbar, .filter-bar, .btn, .pagination { display: none !important; }
  .main-content { margin-left: 0; }
  .page-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
