/* ============================================================
   Gifternise CSS Framework
   ============================================================ */

:root {
  --primary:       #6c63ff;
  --primary-dark:  #5249cc;
  --primary-light: #ede9ff;
  --secondary:     #ff6584;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;
  --text:          #1a1a2e;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --bg:            #f9fafb;
  --white:         #ffffff;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --font:          'Inter', 'Segoe UI', system-ui, sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; height: auto; }

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.375rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: .875rem; }

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

/* ============================================================
   Layout
   ============================================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.container-sm { max-width: 800px; margin: 0 auto; padding: 0 1.5rem; }

.row { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.col { flex: 1; min-width: 0; }
.col-auto { flex: 0 0 auto; }
.col-6 { flex: 0 0 calc(50% - .75rem); }
.col-4 { flex: 0 0 calc(33.333% - 1rem); }
.col-3 { flex: 0 0 calc(25% - 1.125rem); }
.col-12 { flex: 0 0 100%; max-width: 100%; }
@media (min-width: 1024px) {
  .col-lg-8 { flex: 0 0 calc(66.666% - .5rem); max-width: calc(66.666% - .5rem); }
  .col-lg-4 { flex: 0 0 calc(33.333% - 1rem); max-width: calc(33.333% - 1rem); }
  .col-lg-6 { flex: 0 0 calc(50% - .75rem); max-width: calc(50% - .75rem); }
  .col-lg-3 { flex: 0 0 calc(25% - 1.125rem); max-width: calc(25% - 1.125rem); }
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; margin: 0; }
.card-body { }
.card-footer {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.5;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

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

.btn-secondary { background: var(--white); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #16a34a; color: var(--white); }

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

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

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

.btn-sm { padding: .3rem .875rem; font-size: .8125rem; }
.btn-lg { padding: .75rem 2rem; font-size: 1rem; }
.btn-icon { padding: .5rem; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .375rem; color: var(--text); }
.form-label .required { color: var(--danger); margin-left: .2rem; }

.form-control {
  display: block;
  width: 100%;
  padding: .5rem .875rem;
  font-size: .9375rem;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s ease, box-shadow .15s ease;
  appearance: none;
  line-height: 1.5;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,.15);
}
.form-control.is-invalid { border-color: var(--danger); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' viewBox='0 0 12 8'%3E%3Cpath stroke='%236b7280' stroke-width='1.5' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .875rem center; padding-right: 2.5rem; }

/* form-select alias */
.form-select {
  display: block; width: 100%;
  padding: .5rem 2.5rem .5rem .875rem;
  font-size: .9375rem; color: var(--text); background-color: var(--white);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' viewBox='0 0 12 8'%3E%3Cpath stroke='%236b7280' stroke-width='1.5' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .875rem center;
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
  appearance: none; line-height: 1.5; cursor: pointer;
}
.form-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,99,255,.15); }

.form-text { font-size: .8125rem; color: var(--text-muted); margin-top: .25rem; }
.form-error { font-size: .8125rem; color: var(--danger); margin-top: .25rem; }

.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check input[type="checkbox"], .form-check input[type="radio"] { width: 1rem; height: 1rem; accent-color: var(--primary); flex-shrink: 0; }

.input-group { display: flex; }
.input-group .form-control { flex: 1; border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; }

.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.table th {
  background: var(--bg);
  font-weight: 600;
  font-size: .8125rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafa; }
.table-striped tr:nth-child(even) td { background: #f9fafb; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .625rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-secondary { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge-info { background: #dbeafe; color: #1d4ed8; }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: .875rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-success { background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.alert-danger  { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.alert-info    { background: #dbeafe; border-color: #bfdbfe; color: #1e40af; }

/* ============================================================
   Modals
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 2rem; max-width: 560px; width: 90%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-title { font-size: 1.125rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.25rem; padding: .25rem; }
.modal-footer { margin-top: 1.5rem; display: flex; gap: .75rem; justify-content: flex-end; }

/* ============================================================
   Sidebar App Layout
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-brand .brand-logo { width: 32px; height: 32px; object-fit: contain; }
.sidebar-brand .brand-text { font-size: 1.125rem; font-weight: 700; color: var(--primary); }

.sidebar-nav { padding: 1rem 0; flex: 1; }
.nav-section { margin-bottom: .25rem; }
.nav-section-label {
  font-size: .7rem; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-muted);
  padding: .75rem 1.25rem .25rem;
}
.nav-item { list-style: none; }
.nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .625rem 1.25rem; color: var(--text-muted);
  font-size: .9rem; font-weight: 500;
  transition: all .15s; border-radius: 0;
  text-decoration: none;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-light); color: var(--primary); }
.nav-link svg { flex-shrink: 0; opacity: .7; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; gap: .75rem; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem; flex-shrink: 0;
}
.user-name { font-size: .875rem; font-weight: 600; line-height: 1.3; }
.user-role { font-size: .75rem; color: var(--text-muted); }

.app-main {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: .875rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 1.125rem; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }

.content-area { padding: 2rem 1.75rem; flex: 1; }

/* ============================================================
   Stats Cards
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.25rem; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; }
.stat-icon { width: 44px; height: 44px; border-radius: var(--radius); background: var(--primary-light); display: flex; align-items: center; justify-content: center; margin-bottom: .875rem; color: var(--primary); }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.stat-change { font-size: .8rem; margin-top: .5rem; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   Empty States
   ============================================================ */
.empty-state { text-align: center; padding: 3rem 2rem; }
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { font-size: 1.125rem; margin-bottom: .5rem; }
.empty-state p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination { display: flex; align-items: center; gap: .375rem; }
.page-item a, .page-item span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: var(--radius);
  font-size: .875rem; border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  transition: all .15s;
}
.page-item.active span { background: var(--primary); color: var(--white); border-color: var(--primary); }
.page-item a:hover { background: var(--bg); }

/* ============================================================
   Utilities
   ============================================================ */
.d-flex { display: flex; }
.d-none { display: none; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-small { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.fw-600 { font-weight: 600; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.p-0 { padding: 0; }
.rounded { border-radius: var(--radius); }
.rounded-full { border-radius: 999px; }
.shadow { box-shadow: var(--shadow); }
.border { border: 1px solid var(--border); }
.bg-white { background: var(--white); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ============================================================
   Tab Navigation
   ============================================================ */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
}
.tab-link {
  padding: 0.625rem 1.25rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tab-link:hover { color: var(--primary); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============================================================
   Input group
   ============================================================ */
.input-group { display: flex; }
.input-group-text {
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.input-group .form-control { border-radius: 0 var(--radius) var(--radius) 0; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .col-6, .col-4, .col-3 { flex: 0 0 100%; }
  .content-area { padding: 1.25rem 1rem; }
  .topbar { padding: .75rem 1rem; }
  .form-row { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.375rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { padding: 1.25rem; }
}
