/* ============================
   Ticari Hesaplar — Premium Light Theme
   ============================ */

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

:root {
  /* Color System */
  --bg: #f4f6fb;
  --bg-alt: #eef1f8;
  --surface: #ffffff;
  --surface-hover: #f8f9fd;
  --surface-alt: #f0f2f8;
  --border: #e2e6ef;
  --border-light: #edf0f7;

  /* Brand */
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --primary-hover: #4338ca;
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);

  /* Semantic */
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --info: #2563eb;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;

  /* Text */
  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);

  /* Sizing */
  --sidebar-w: 280px;
  --topbar-h: 58px;
  --bnav-h: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============ LOGIN PAGE ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: 
    radial-gradient(at 20% 50%, rgba(79, 70, 229, 0.08) 0%, transparent 50%),
    radial-gradient(at 80% 20%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
    radial-gradient(at 50% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
}

.login-card {
  width: 400px;
  max-width: 92vw;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  animation: fadeUp 0.5s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.login-logo .icon {
  width: 56px;
  height: 56px;
  background: var(--primary-gradient);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

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

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.login-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 14px;
  display: none;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-alt); }

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.btn-full { width: 100%; padding: 12px; font-size: 14px; }

/* ============ APP LAYOUT ============ */
#app {
  display: none;
  height: 100dvh;
}

#app.active {
  display: flex;
}

/* ============ SIDEBAR ============ */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--primary-gradient);
  color: white;
}

.sidebar-header h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.sidebar-header .subtitle {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 3px;
  font-weight: 400;
}

.sidebar-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.sidebar-search input:focus {
  border-color: var(--primary);
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.firm-item {
  padding: 10px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: all 0.12s ease;
}

.firm-item:hover { background: var(--surface-hover); }
.firm-item.active {
  background: var(--primary-light);
  border-left-color: var(--primary);
}

.firm-name {
  font-size: 12px;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.firm-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.badge-debt { background: var(--danger-bg); color: var(--danger); }
.badge-clear { background: var(--success-bg); color: var(--success); }
.badge-zero { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

/* ============ MAIN AREA ============ */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

/* Topbar */
#topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

#topbar h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

#topbar .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Stats Bar */
.stats-bar {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.stats-bar.visible { display: grid; }

.stat-item {
  padding: 10px 18px;
  border-right: 1px solid var(--border);
}

.stat-item:last-child { border-right: none; }

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Content */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  -webkit-overflow-scrolling: touch;
}

/* ============ WELCOME VIEW ============ */
.welcome-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
}

.welcome-view .emoji { font-size: 52px; }

/* ============ DASHBOARD ============ */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.summary-card .label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 4px;
}

.summary-card .value {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.summary-card .sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Panel Card */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  gap: 10px;
}

.panel-header h3 {
  font-size: 13px;
  font-weight: 700;
  flex: 1;
}

.panel-body { padding: 14px 16px; }

/* Rank Item */
.rank-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 8px;
}

.rank-item:last-child { border-bottom: none; }

.rank-name {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
  transition: color 0.15s;
}

.rank-name:hover { color: var(--primary-hover); text-decoration: underline; }

.rank-value {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ============ NOTES ============ */
.note-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.note-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  gap: 8px;
}

.note-header h4 {
  font-size: 12px;
  font-weight: 700;
  flex: 1;
}

.note-body { padding: 12px 14px; }

.note-add {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.note-add input {
  flex: 1;
  padding: 8px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}

.note-add input:focus { border-color: var(--primary); }

.note-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  transition: border-color 0.15s;
}

.note-item:hover { border-color: var(--border); }

.note-item .note-text {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.5;
}

.note-item .note-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.note-item .note-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.note-item:hover .note-delete { opacity: 1; }
.note-item .note-delete:hover { color: var(--danger); }

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 14px;
  background: var(--bg-alt);
  border-radius: 8px;
  padding: 3px;
  width: fit-content;
}

.tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  user-select: none;
}

.tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

/* ============ TABLE ============ */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead { background: var(--surface-alt); }

th {
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 8px 12px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  vertical-align: middle;
}

tr:hover td { background: var(--surface-hover); }

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.date-cell {
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.note-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: #fef3c7;
  color: #b45309;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #fde68a;
  margin-top: 4px;
}

.usd-badge {
  display: inline-block;
  font-size: 10px;
  background: var(--info-bg);
  color: var(--info);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  border: 1px solid var(--info-border);
}

.table-footer {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  gap: 20px;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}

.delete-btn:hover { opacity: 1; color: var(--danger); }

/* ============ SETTINGS ============ */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.setting-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.setting-card h4 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* ============ KUR PANEL ============ */
.kur-panel {
  background: linear-gradient(135deg, var(--info-bg), #f5f3ff);
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.kur-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--info);
}

.kur-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kur-input-group input {
  width: 90px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
  outline: none;
}

.kur-input-group input:focus { border-color: var(--primary); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s;
}

.modal-overlay.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 440px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: -0.3px;
}

.modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ============ MOBILE SIDEBAR MODAL ============ */
#sidebarModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.5);
}

#sidebarModalInner {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 82%;
  max-width: 320px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  animation: slideRight 0.2s ease;
}

@keyframes slideRight {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

/* ============ BOTTOM NAV (MOBILE) ============ */
#bottomNav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bnav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}

.bnav-inner { display: flex; height: 100%; }

.bnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  font-family: inherit;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.bnav-btn .bnav-icon { font-size: 20px; line-height: 1; }
.bnav-btn.active { color: var(--primary); }

.bnav-add-icon {
  font-size: 22px;
  background: var(--primary-gradient);
  color: white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* Color Utilities */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-muted { color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 28px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  #sidebar { display: none; }
  #bottomNav { display: block; }
  
  #content { padding: 12px 12px calc(var(--bnav-h) + 12px); }
  #topbar { padding: 10px 14px; }
  #topbar h2 { font-size: 14px; }
  
  .stats-bar .stat-value { font-size: 14px; }
  .stats-bar .stat-item { padding: 8px 12px; }
  
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .modal-row { grid-template-columns: 1fr; }
  
  .tabs { overflow-x: auto; width: 100%; }
  table { font-size: 11px; }
  th, td { padding: 6px 8px; }
  .modal { width: 95vw; padding: 18px; }
}

/* ============ TRANSITION ============ */
.fade-in {
  animation: fadeIn 0.2s ease;
}

/* User menu */
.user-menu {
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}

.user-btn:hover { background: var(--border); }

.user-avatar {
  width: 24px;
  height: 24px;
  background: var(--primary-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
}
