/* ===== Kantin Kart Sistemi - Styles ===== */
:root {
  --primary: #4361ee;
  --primary-dark: #3a56d4;
  --success: #2ecc71;
  --success-dark: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --orange: #e67e22;
  --purple: #9b59b6;
  --bg: #f0f2f5;
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #16213e;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-muted: #7f8c8d;
  --border: #e0e6ed;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --sidebar-width: 260px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-header { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 28px; }
.logo-text { font-size: 18px; font-weight: 700; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 8px;
  color: rgba(255,255,255,0.7); text-decoration: none;
  transition: all 0.2s; margin-bottom: 4px; cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: 20px; width: 24px; text-align: center; }
.nav-label { font-size: 14px; font-weight: 500; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); color: rgba(255,255,255,0.4); }

.main {
  flex: 1; margin-left: var(--sidebar-width);
  display: flex; flex-direction: column; min-height: 100vh;
}

.topbar {
  background: var(--card-bg); padding: 16px 28px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 22px; font-weight: 600; flex: 1; }
.datetime { color: var(--text-muted); font-size: 13px; }

.content { padding: 24px 28px; flex: 1; }

.page { display: none; }
.page.active { display: block; }

/* ===== Cards & Stats ===== */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

.welcome-banner {
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff; padding: 32px; border-radius: var(--radius);
  margin-bottom: 24px;
}
.welcome-banner h2 { font-size: 28px; margin-bottom: 4px; }
.welcome-banner p { opacity: 0.85; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.stat-icon { font-size: 36px; }
.stat-value { display: block; font-size: 24px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-blue { border-left: 4px solid var(--primary); }
.stat-green { border-left: 4px solid var(--success); }
.stat-orange { border-left: 4px solid var(--orange); }
.stat-purple { border-left: 4px solid var(--purple); }

.dashboard-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[disabled] {
  opacity: 0.45; cursor: not-allowed; pointer-events: none;
}
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; padding: 8px; border-radius: 6px; }
.btn-icon:hover { background: var(--bg); }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Forms ===== */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.input {
  padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
  transition: border-color 0.2s; background: #fff;
}
.input:focus { outline: none; border-color: var(--primary); }
.input-lg { padding: 14px 18px; font-size: 18px; text-align: center; }

.page-header {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 20px; flex-wrap: wrap;
}
.search-box { flex: 1; min-width: 200px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 10px 12px;
  background: var(--bg); font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tr:hover { background: #fafbfc; }
.row-warning { background: #fff8e1 !important; }

/* ===== Badges ===== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green { background: #d4edda; color: #155724; }
.badge-red { background: #f8d7da; color: #721c24; }
.badge-orange { background: #fff3cd; color: #856404; }
.badge-gray { background: #e9ecef; color: #6c757d; }

.text-green { color: var(--success); font-weight: 600; }
.text-red { color: var(--danger); font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }

/* ===== Student Cards ===== */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px;
}

.student-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: transform 0.2s;
}
.student-card:hover { transform: translateY(-2px); }

.student-card-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.student-card-header h4 { font-size: 15px; }
.student-card-body { padding: 16px 20px; }
.info-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.student-card-actions {
  display: flex; gap: 8px; padding: 12px 20px;
  border-top: 1px solid var(--border); background: var(--bg);
}

.student-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.student-avatar.lg { width: 64px; height: 64px; font-size: 28px; }

/* ===== Scanner ===== */
.scanner-box {
  width: 100%; max-width: 320px; margin: 0 auto;
  border-radius: var(--radius); overflow: hidden;
  background: #000; min-height: 200px;
}
.scanner-sm { max-width: 240px; min-height: 160px; }
.scanner-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.scanner-fallback, .scanner-error { padding: 40px 20px; text-align: center; color: var(--text-muted); }

.qr-display { display: flex; justify-content: center; margin-bottom: 16px; }
.qr-modal { text-align: center; }

/* ===== Balance ===== */
.balance-layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px;
}
.balance-scan-card { text-align: center; }
.manual-input { display: flex; gap: 10px; margin-top: 16px; }
.balance-student { text-align: center; }
.balance-student h3 { margin: 12px 0 4px; }
.current-balance {
  background: var(--bg); padding: 16px; border-radius: var(--radius);
  margin: 20px 0;
}
.current-balance span { display: block; font-size: 13px; color: var(--text-muted); }
.current-balance strong { font-size: 32px; color: var(--success); }
.quick-amounts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 12px; }

/* ===== POS ===== */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; }
.pos-scan { margin-bottom: 0; }
.pos-scan-header { text-align: center; margin-bottom: 16px; }
.pos-scan-header .manual-input { display: flex; gap: 10px; margin-top: 12px; }
.pos-student-display { padding: 16px; background: var(--bg); border-radius: var(--radius); min-height: 72px; }

.direct-sale-card { border: 2px solid var(--success); }
.direct-sale-card h3 { color: var(--success-dark); }
.direct-sale-card .quick-amounts { margin: 12px 0 16px; }

.product-details { margin-top: 16px; }
.product-details summary {
  cursor: pointer; font-weight: 600; padding: 4px 0 12px;
  color: var(--text-muted);
}
.product-details[open] summary { margin-bottom: 12px; color: var(--text); }
.pos-student-info { display: flex; align-items: center; gap: 12px; }
.pos-balance { margin-left: auto; text-align: right; }
.pos-balance span { display: block; font-size: 11px; color: var(--text-muted); }
.pos-balance strong { font-size: 20px; }

.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; margin-top: 12px; max-height: 400px; overflow-y: auto;
}
.product-btn {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius); background: #fff; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
}
.product-btn:hover:not(:disabled) { border-color: var(--primary); background: #f0f4ff; }
.product-btn.out-of-stock { opacity: 0.4; cursor: not-allowed; }
.product-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.product-price { color: var(--primary); font-weight: 700; font-size: 15px; }
.product-stock { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.pos-cart { position: sticky; top: 80px; }
.cart-items { max-height: 300px; overflow-y: auto; margin-bottom: 16px; }
.cart-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.cart-item-info strong { display: block; font-size: 14px; }
.cart-item-info span { font-size: 12px; color: var(--text-muted); }
.cart-item-actions { display: flex; align-items: center; gap: 8px; }
.cart-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0; border-top: 2px solid var(--border);
  font-size: 18px; margin-bottom: 16px;
}
.cart-total strong { color: var(--primary); font-size: 24px; }

/* ===== Ledger ===== */
.ledger-summary {
  display: flex; gap: 24px; padding: 12px 0 16px;
  font-weight: 600; font-size: 14px; flex-wrap: wrap;
}

/* ===== Top Products ===== */
.top-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.top-rank {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.top-name { flex: 1; font-weight: 500; }
.top-qty { color: var(--text-muted); font-size: 13px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--card-bg); border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

/* ===== Toast ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; }
.toast {
  background: var(--card-bg); padding: 14px 20px; border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15); margin-bottom: 8px;
  transform: translateX(120%); transition: transform 0.3s;
  border-left: 4px solid var(--success); font-size: 14px; max-width: 360px;
}
.toast.show { transform: translateX(0); }
.toast-error { border-left-color: var(--danger); }

/* ===== Empty States ===== */
.empty, .empty-state { text-align: center; color: var(--text-muted); padding: 40px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

.alert { padding: 14px 20px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }

code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .pos-layout { grid-template-columns: 1fr; }
  .balance-layout { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(var(--sidebar-width), 85vw);
    z-index: 110;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  }

  .sidebar-backdrop.active {
    display: block;
  }

  body.sidebar-active {
    overflow: hidden;
  }

  .main { margin-left: 0; }
  .content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .topbar .datetime { display: none; }
}

@media print {
  .sidebar, .topbar, .btn { display: none !important; }
  .main { margin-left: 0; }
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #4361ee 100%);
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.login-header h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  background: #fdecea;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 0;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-muted);
}
