/* ==========================================================================
   KOPERASI GATRA MANDIRI - DESIGN SYSTEM & STYLESHEET
   Clean, Modern, Responsive, and Print-Ready
   ========================================================================== */

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

:root {
  /* Color Palette */
  --primary: #059669;
  --primary-hover: #047857;
  --primary-light: #ecfdf5;
  --primary-dark: #064e3b;
  --primary-border: #a7f3d0;

  --secondary: #0f172a;
  --secondary-light: #1e293b;
  --secondary-muted: #64748b;

  --accent: #2563eb;
  --accent-light: #eff6ff;

  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #0284c7;
  --info-light: #e0f2fe;

  /* Surfaces & Backgrounds */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #10b981;

  /* Text Colors */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-inverse: #ffffff;

  /* Elevation / Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px -1px rgba(0, 0, 0, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 10px -2px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 30px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 70px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

/* App Wrapper for Dashboard */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ==========================================================================
   SIDEBAR STYLES
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  background-color: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.3);
}

.brand-info h1 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--secondary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-info span {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  padding: 12px 14px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--secondary-muted);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: var(--transition);
}

.nav-link:hover {
  background-color: var(--bg-subtle);
  color: var(--primary);
}

.nav-link.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.nav-link.active svg {
  color: var(--primary);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background-color: #fafbfc;
}

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

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 9999px;
  background-color: var(--primary-light);
  color: var(--primary-dark);
}

.btn-logout {
  padding: 6px;
  color: var(--text-muted);
  border-radius: 6px;
  transition: var(--transition);
}

.btn-logout:hover {
  color: var(--danger);
  background-color: var(--danger-light);
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-navbar {
  height: var(--header-height);
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-main);
}

.page-title-box h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--secondary);
  letter-spacing: -0.01em;
}

.page-title-box p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.date-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  background-color: var(--bg-subtle);
  padding: 7px 14px;
  border-radius: 9999px;
  color: var(--secondary-muted);
}

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

/* ==========================================================================
   CARDS & GRIDS
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 22px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.green {
  background-color: var(--primary-light);
  color: var(--primary);
}

.stat-icon.blue {
  background-color: var(--accent-light);
  color: var(--accent);
}

.stat-icon.amber {
  background-color: var(--warning-light);
  color: var(--warning);
}

.stat-icon.red {
  background-color: var(--danger-light);
  color: var(--danger);
}

.stat-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.stat-hint {
  font-size: 0.75rem;
  margin-top: 6px;
  color: var(--text-subtle);
}

/* Standard Content Card */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background-color: #ffffff;
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--secondary);
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-body {
  padding: 24px;
}

/* ==========================================================================
   BUTTONS & BADGES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  line-height: 1.25;
  font-family: inherit;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.btn-secondary {
  background-color: #ffffff;
  border-color: var(--border-color);
  color: var(--secondary);
}
.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: #cbd5e1;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background-color: #dc2626;
}

.btn-warning {
  background-color: var(--warning);
  color: #ffffff;
}
.btn-warning:hover {
  background-color: #d97706;
}

.btn-outline-primary {
  background-color: transparent;
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline-primary:hover {
  background-color: var(--primary-light);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.btn-icon svg {
  width: 15px;
  height: 15px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.badge-success {
  background-color: var(--success-light);
  color: #065f46;
}
.badge-warning {
  background-color: var(--warning-light);
  color: #92400e;
}
.badge-danger {
  background-color: var(--danger-light);
  color: #991b1b;
}
.badge-info {
  background-color: var(--info-light);
  color: #075985;
}
.badge-neutral {
  background-color: var(--bg-subtle);
  color: var(--secondary-muted);
}

/* ==========================================================================
   TABLES & DATA DISPLAY
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table-freeze-container {
  width: 100%;
  max-height: calc(100vh - 240px);
  min-height: 380px;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
}

.table-freeze-container .table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #f8fafc;
  box-shadow: 0 1px 0 var(--border-color);
}

.table-freeze-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.table-freeze-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 0.875rem;
}

.table th {
  background-color: #f8fafc;
  color: var(--secondary-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  color: var(--text-main);
}

.table tbody tr:hover {
  background-color: #fafbfc;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-amount,
.table td.table-amount,
.table th.table-amount,
.table td[style*="text-align: right"],
.table td[style*="text-align:right"],
.table th[style*="text-align: right"],
.table th[style*="text-align:right"],
.table tfoot td,
.table tfoot th,
.stat-value,
.badge-amount,
[class*="table-amount"],
.nominal-nowrap {
  font-family: monospace, sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap !important;
  word-break: keep-all !important;
}
.text-green { color: var(--primary); }
.text-red { color: var(--danger); }
.text-blue { color: var(--accent); }

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 6px;
}

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-main);
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  outline: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.form-text {
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-top: 4px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-col {
  flex: 1;
}

/* ==========================================================================
   ALERTS
   ========================================================================== */
.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  font-size: 0.875rem;
  animation: fadeIn 0.3s ease;
}

.alert-success {
  background-color: var(--success-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.alert-danger {
  background-color: var(--danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}
.alert-warning {
  background-color: var(--warning-light);
  color: #92400e;
  border: 1px solid #fde68a;
}
.alert-info {
  background-color: var(--info-light);
  color: #075985;
  border: 1px solid #bae6fd;
}

.alert-icon {
  display: flex;
  align-items: center;
}

.alert-content {
  flex: 1;
}

.alert-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: inherit;
  cursor: pointer;
  opacity: 0.6;
}
.alert-close:hover { opacity: 1; }

/* ==========================================================================
   MEMBER DIGITAL CARD (KARTU ANGGOTA KOPERASI ELEGAN)
   ========================================================================== */
.member-card-gold {
  background: linear-gradient(135deg, #064e3b 0%, #047857 50%, #059669 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 26px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 15px 35px -5px rgba(5, 150, 105, 0.4);
  max-width: 480px;
  margin-bottom: 24px;
}

.member-card-gold::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
}

.member-card-gold::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: -40px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
}

.card-chip {
  width: 44px;
  height: 32px;
  background: linear-gradient(135deg, #fcd34d, #f59e0b);
  border-radius: 6px;
  margin-bottom: 18px;
  position: relative;
  border: 1px solid rgba(0,0,0,0.1);
}

.card-number {
  font-family: monospace, sans-serif;
  font-size: 1.25rem;
  letter-spacing: 2px;
  margin-bottom: 14px;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.card-holder {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.card-holder-name {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-holder-since {
  font-size: 0.72rem;
  opacity: 0.85;
}

/* ==========================================================================
   LOGIN PAGE SPECIFIC STYLES
   ========================================================================== */
.login-page-body {
  background: linear-gradient(135deg, #f0fdf4 0%, #f8fafc 50%, #eff6ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-container {
  width: 100%;
  max-width: 440px;
  background-color: #ffffff;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  padding: 36px 32px;
  position: relative;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: var(--radius-md);
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
}

.login-brand h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--secondary);
}

.login-brand p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.demo-account-box {
  background-color: #f8fafc;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 24px;
}

.demo-account-box h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.demo-btn-group {
  display: flex;
  gap: 8px;
}

.btn-demo-fill {
  flex: 1;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--secondary);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.btn-demo-fill:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary-dark);
}

/* ==========================================================================
   MODAL DIALOG
   ========================================================================== */
.modal-overlay, .modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active, .modal.active {
  display: flex !important;
}

.modal-card, .modal-dialog {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--secondary);
}

.modal-close-btn, .modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-subtle);
  cursor: pointer;
  line-height: 1;
}
.modal-close-btn:hover, .modal-close:hover { color: var(--danger); }

.modal-body {
  padding: 24px;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: #f8fafc;
}

/* ==========================================================================
   PRINT STYLES FOR FINANCIAL REPORTS
   ========================================================================== */
@media print {
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
  }
  .sidebar, .top-navbar, .btn, .card-header-actions, .demo-account-box, .no-print {
    display: none !important;
  }
  .main-wrapper {
    margin-left: 0 !important;
  }
  .content-body {
    padding: 0 !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
  }
  .print-header {
    display: block !important;
    text-align: center;
    border-bottom: 2px solid #000;
    padding-bottom: 12px;
    margin-bottom: 20px;
  }
  .table th, .table td {
    border-color: #333 !important;
    padding: 8px !important;
  }
}

.print-header {
  display: none;
}

/* Responsive adjustments */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .mobile-toggle {
    display: block;
  }
  .top-navbar {
    padding: 0 16px;
  }
  .content-body {
    padding: 20px 16px;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
