/* ============================================
   Label Undangan - Main Stylesheet
   Font: Playfair Display + DM Sans
   Tema: Warm Elegant (Krem & Emas)
============================================ */

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

:root {
  --cream:     #FAF6F0;
  --warm-white:#FFFDF9;
  --gold:      #C9A84C;
  --gold-light:#E8C97A;
  --gold-dark: #9A7A2E;
  --brown:     #4A3728;
  --brown-mid: #6B5240;
  --brown-light:#A08060;
  --text:      #2D2018;
  --text-muted:#7A6555;
  --border:    #E8D9C5;
  --danger:    #C0392B;
  --success:   #27AE60;
  --info:      #2980B9;

  --radius:    10px;
  --shadow-sm: 0 2px 8px rgba(74,55,40,.10);
  --shadow:    0 4px 20px rgba(74,55,40,.14);
  --shadow-lg: 0 8px 40px rgba(74,55,40,.18);
  --transition:0.22s ease;

  /* Label 103: 32x64mm, 12/halaman, 3 kolom × 4 baris */
  --label-w:   64mm;
  --label-h:   32mm;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

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

/* ========== SIDEBAR ========== */
.sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--brown);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.sidebar-brand {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(201,168,76,.2);
}
.sidebar-brand .brand-icon {
  width: 46px; height: 46px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  font-size: 22px;
}
.sidebar-brand h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--gold-light);
  line-height: 1.3;
}
.sidebar-brand span {
  font-size: .75rem;
  color: var(--brown-light);
  font-weight: 300;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
}
.nav-section {
  padding: 8px 24px 4px;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--brown-light);
  font-weight: 600;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 400;
  transition: var(--transition);
  border-left: 3px solid transparent;
  margin: 1px 0;
}
.nav-link:hover {
  background: rgba(201,168,76,.12);
  color: var(--gold-light);
  border-left-color: var(--gold);
}
.nav-link.active {
  background: rgba(201,168,76,.18);
  color: var(--gold-light);
  border-left-color: var(--gold);
  font-weight: 500;
}
.nav-link .icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(201,168,76,.15);
}
.user-info {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--brown); font-size: .85rem;
}
.user-name { font-size: .82rem; color: rgba(255,255,255,.85); font-weight: 500; }
.user-role {
  font-size: .7rem; color: var(--gold-light);
  background: rgba(201,168,76,.15);
  padding: 1px 8px; border-radius: 20px;
}
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 14px;
  background: rgba(192,57,43,.15);
  border: 1px solid rgba(192,57,43,.3);
  color: #E57373;
  border-radius: 8px; font-size: .83rem;
  cursor: pointer; text-decoration: none;
  transition: var(--transition);
}
.btn-logout:hover { background: rgba(192,57,43,.28); }

/* ========== MAIN CONTENT ========== */
.main {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--warm-white);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--brown);
}
.breadcrumb {
  font-size: .78rem;
  color: var(--text-muted);
}
.breadcrumb a { color: var(--gold-dark); text-decoration: none; }

.content {
  padding: 32px;
  flex: 1;
}

/* ========== CARDS ========== */
.card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  color: var(--brown);
}
.card-body { padding: 24px; }

/* ========== STAT CARDS ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
}
.stat-icon {
  font-size: 2rem; margin-bottom: 10px; display: block;
}
.stat-value {
  font-family: 'Playfair Display', serif;
  font-size: 2rem; font-weight: 700;
  color: var(--brown);
}
.stat-label { font-size: .82rem; color: var(--text-muted); }

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: .875rem; font-weight: 500;
  cursor: pointer; text-decoration: none;
  border: none;
  transition: var(--transition);
  font-family: 'DM Sans', sans-serif;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--brown);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(201,168,76,.4);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--cream);
  color: var(--brown);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger {
  background: #FDECEC;
  color: var(--danger);
  border: 1px solid #F5C6C6;
}
.btn-danger:hover { background: #F5C6C6; }
.btn-success {
  background: #EAF7EF;
  color: var(--success);
  border: 1px solid #C6E9D4;
}
.btn-sm { padding: 5px 12px; font-size: .8rem; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .84rem; font-weight: 500;
  color: var(--brown-mid);
  margin-bottom: 6px;
}
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem; font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--warm-white);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,.15);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: 16px; height: 16px; accent-color: var(--gold); }

/* ========== TABLES ========== */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  background: var(--cream);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover { background: var(--cream); }
tbody tr:last-child td { border-bottom: none; }

/* ========== ALERTS ========== */
.alert {
  padding: 12px 18px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: .875rem;
  border-left: 4px solid;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: #EAF7EF; border-color: var(--success); color: #1E8449; }
.alert-danger   { background: #FDECEC; border-color: var(--danger);  color: #A93226; }
.alert-info     { background: #EBF5FB; border-color: var(--info);    color: #1A6FA8; }
.alert-warning  { background: #FEF9E7; border-color: #F39C12;        color: #9A6D00; }

/* ========== BADGE ========== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}
.badge-gold    { background: rgba(201,168,76,.15); color: var(--gold-dark); }
.badge-success { background: #EAF7EF; color: var(--success); }
.badge-danger  { background: #FDECEC; color: var(--danger); }
.badge-info    { background: #EBF5FB; color: var(--info); }

/* ========== PAGINATION ========== */
.pagination {
  display: flex; align-items: center; gap: 6px;
  padding: 16px 0 0;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px; font-size: .83rem;
  text-decoration: none; color: var(--brown-mid);
  transition: var(--transition);
}
.pagination a:hover { background: var(--cream); border-color: var(--gold); }
.pagination .active { background: var(--gold); border-color: var(--gold); color: var(--brown); font-weight: 700; }

/* ========== MODAL ========== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(45,32,24,.55);
  z-index: 200;
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--warm-white);
  border-radius: 14px;
  width: 90%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform: translateY(-16px) scale(.97); } }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-family: 'Playfair Display', serif; font-size: 1.1rem; color: var(--brown); }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--cream); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ========== LOGIN PAGE ========== */
.login-page {
  min-height: 100vh;
  background: var(--brown);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 40px,
    rgba(201,168,76,.03) 40px,
    rgba(201,168,76,.03) 80px
  );
}
.login-box {
  background: var(--warm-white);
  border-radius: 18px;
  padding: 48px 44px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px; margin-bottom: 14px;
}
.login-logo h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem; color: var(--brown);
}
.login-logo p { font-size: .85rem; color: var(--text-muted); }
.login-divider {
  text-align: center; margin: 20px 0;
  font-size: .75rem; color: var(--text-muted);
  position: relative;
}
.login-divider::before, .login-divider::after {
  content: '';
  position: absolute; top: 50%;
  width: 40%; height: 1px;
  background: var(--border);
}
.login-divider::before { left: 0; }
.login-divider::after  { right: 0; }

/* ========== PRINT - LABEL No. 103 (32x64mm) ========== */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  body { margin: 0; padding: 0; background: #fff; }
  .no-print { display: none !important; }

  .print-wrapper {
    width: 210mm;
    min-height: 297mm;
    padding: 13mm 8mm;
    margin: 0 auto;
  }

  .label-grid {
    display: grid;
    grid-template-columns: repeat(3, 64mm);
    grid-template-rows: repeat(4, 32mm);
    gap: 3mm 2mm;
    page-break-after: always;
  }

  .label-item {
    width: 64mm;
    height: 32mm;
    border: 0.5pt solid #ccc;
    padding: 2.5mm 3mm;
    overflow: hidden;
    font-size: 7pt;
    line-height: 1.35;
    font-family: Arial, sans-serif;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
  }

  .label-item.empty {
    border: 0.5pt dashed #ddd;
  }

  .label-to {
    font-size: 6pt;
    color: #888;
    margin-bottom: 1mm;
    text-transform: uppercase;
    letter-spacing: .05em;
    text-align: center;
    width: 100%;
  }
  .label-name {
    font-size: 8.5pt;
    font-weight: bold;
    color: #000;
    margin-bottom: 0.8mm;
    line-height: 1.2;
    text-align: center;
    width: 100%;
  }
  .label-address {
    font-size: 7pt;
    color: #222;
    line-height: 1.3;
    text-align: center;
    width: 100%;
  }
  .label-city {
    font-size: 7pt;
    font-weight: 600;
    color: #000;
    margin-top: 0.5mm;
    text-align: center;
    width: 100%;
  }
  .label-kodepos { font-size: 6.5pt; color: #444; text-align: center; width: 100%; }
}

/* Preview label (screen) */
@media screen {
  .print-preview-area { display: none; }
  .print-preview-area.show { display: block; }

  .label-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 720px;
  }
  .label-preview-item {
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: .75rem;
    min-height: 80px;
    background: #fff;
    position: relative;
  }
  .label-preview-item.has-data { border-color: var(--gold); border-style: solid; }
  .label-badge {
    position: absolute; top: 4px; right: 6px;
    font-size: .65rem; color: var(--brown-light);
  }
  .lp-to { font-size: .65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
  .lp-name { font-weight: 600; color: var(--brown); margin: 2px 0 1px; font-size: .8rem; }
  .lp-addr { color: var(--text-muted); font-size: .72rem; line-height: 1.4; }
  .lp-city { font-weight: 600; font-size: .75rem; color: var(--brown); margin-top: 2px; }
}

/* ========== SELECT ALL CHECKBOX ========== */
.select-all-row { background: rgba(201,168,76,.05) !important; }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .sidebar { width: 220px; }
  .main { margin-left: 220px; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .content { padding: 20px 16px; }
  .label-preview-grid { grid-template-columns: 1fr 1fr; }
}

/* ========== UTILITIES ========== */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-0  { margin-bottom: 0 !important; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); font-size: .85rem; }
.text-center { text-align: center; }
.w-100 { width: 100%; }
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; display: block; }
.empty-state p { font-size: .9rem; }
