/* ============================================================
   Şantiye Net Hesap — Ana CSS
   Tasarım: Sade, güçlü, mobil öncelikli, şantiye ruhu.
   ============================================================ */

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Modern SaaS Color Palette - DARK MODE (Default) */
  --bg-dark: #0B101E;
  --bg-panel: rgba(22, 30, 48, 0.65);
  --primary: #FF8C00;
  --primary-hover: #FF7300;
  --success: #10B981;
  --danger: #EF4444;
  --text: #FFFFFF;
  --text-muted: #A0ABBD;
  --border: rgba(255, 255, 255, 0.08);

  --bg:          #0B101E;
  --surface:     rgba(22, 30, 48, 0.65);
  --surface2:    rgba(255, 255, 255, 0.03);
  --accent:      #FF8C00;
  --accent-dark: #FF7300;
  --text-dim:    #7a7f96;
  --sidebar-w:   260px;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 10px 30px rgba(0,0,0,0.3);
  --transition:  .2s cubic-bezier(0.4, 0, 0.2, 1);
  --glow-bg:     radial-gradient(circle at 15% 50%, rgba(255, 140, 0, 0.06), transparent 30%), radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.04), transparent 30%);
}

[data-theme="light"] {
  /* Modern SaaS Color Palette - LIGHT MODE */
  --bg-dark: #F3F4F6;
  --bg-panel: #FFFFFF;
  --primary: #F97316;
  --primary-hover: #EA580C;
  --success: #059669;
  --danger: #DC2626;
  --text: #111827;
  --text-muted: #4B5563;
  --border: #D1D5DB;

  --bg:          #F3F4F6;
  --surface:     #FFFFFF;
  --surface2:    #E5E7EB;
  --accent:      #F97316;
  --accent-dark: #EA580C;
  --text-dim:    #6B7280;
  --shadow:      0 10px 30px rgba(0,0,0,0.08);
  --glow-bg:     none;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-dark);
  background-image: var(--glow-bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  transition: background-color 0.3s, color 0.3s;
  overflow-x: hidden;
}

/* ---- LAYOUT ---- */
body { 
  display: flex; 
  flex-direction: column; 
}

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background-color: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s, border-color 0.3s;
  box-shadow: 4px 0 30px rgba(0,0,0,0.3);
}
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  backdrop-filter: blur(4px);
}
.sidebar-overlay.active {
  display: block;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.sidebar-logo { font-size: 1.8rem; line-height: 1; text-shadow: 0 0 10px rgba(255,140,0,0.3); }
.sidebar-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .5px;
}

/* --- Yazdırma (Print / PDF) Ayarları --- */
@media print {
  @page {
    size: landscape;
    margin: 0.5cm;
  }
  body, html {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
    width: 100% !important;
  }
  
  /* Arayüz elemanlarını gizle */
  .sidebar,
  .btn,
  .td-actions,
  .th-actions,
  .table-controls,
  #prompt-error,
  #table-error,
  .ai-chat-box {
    display: none !important;
  }

  /* Ana tablo ekranı sığsın */
  .app-container {
    padding: 0;
    height: auto;
  }
  .main-content {
    padding: 0;
  }
  .screen-table {
    padding: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }
  .table-container {
    overflow: visible !important;
    border: none !important;
  }
  table {
    width: 100%;
    table-layout: auto;
    page-break-inside: auto;
    border-collapse: collapse;
  }
  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  th, td {
    padding: 6px;
    font-size: 11px;
    color: #000 !important;
    border-color: #ccc !important;
  }
  .cell-input, .header-input {
    color: #000 !important;
    background: transparent !important;
    border: none !important;
    font-size: 11px !important;
    padding: 0 !important;
    font-family: inherit !important;
    font-weight: inherit !important;
  }
}

.sidebar-body { flex: 1; padding: 16px; overflow-y: auto; }
.sidebar-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-empty { color: var(--text-dim); font-size: .85rem; padding: 8px 0; }

.history-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.history-item:hover { 
  background-color: var(--surface2); 
  border-color: var(--border); 
  transform: translateY(-1px);
}
.history-item.active { 
  border-color: var(--primary); 
  background-color: var(--surface2); 
  box-shadow: inset 0 0 0 1px var(--primary);
}
.history-item-title {
  font-size: .88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.history-item-date { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.history-item-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: .9rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--transition);
  flex-shrink: 0;
}
.history-item-delete:hover { color: var(--danger); }

/* ---- MAIN ---- */
.main {
  flex: 1;
  min-height: 100vh;
  padding: 24px;
  overflow-y: auto;
  position: relative;
}

/* ---- SCREENS ---- */
.screen { display: none; }
.screen.active { display: block; }
.screen.hidden { display: none; }

/* ---- PROMPT SCREEN ---- */
.prompt-card {
  max-width: 700px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.prompt-header { margin-bottom: 20px; }
.prompt-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.prompt-subtitle { color: var(--text-muted); font-size: .9rem; }

.prompt-textarea {
  width: 100%;
  background-color: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  color: var(--text);
  font-size: 1rem;
  resize: vertical;
  min-height: 160px;
  margin-bottom: 16px;
  transition: all 0.2s;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.05);
  outline: none;
}
.prompt-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.05), 0 0 0 3px rgba(255, 140, 0, 0.15);
  background-color: var(--surface2);
}
.prompt-textarea::placeholder { color: var(--text-muted); }

.prompt-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.char-count { font-size: .8rem; color: var(--text-muted); }

/* ---- TABLE SCREEN ---- */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.title-input {
  width: 100%;
  background-color: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  max-width: 100%;
  transition: all 0.2s;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
  outline: none;
}
.title-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05), 0 0 0 3px rgba(255, 140, 0, 0.15);
  background-color: var(--surface2);
}

.save-status {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 10px;
  animation: fadeIn .3s ease;
}
.save-status.success { background: rgba(16,185,129,.15); color: var(--success); border: 1px solid var(--success); }
.save-status.error   { background: rgba(239,68,68,.15);  color: var(--danger);  border: 1px solid var(--danger);  }

/* ---- TABLE ---- */
.table-wrapper {
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--border);
  background-color: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.hakedis-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.hakedis-table thead {
  background-color: var(--surface2);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.hakedis-table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.hakedis-table th.th-actions { width: 48px; text-align: center; }

.header-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  width: 100%;
  outline: none;
  cursor: text;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
}
.header-input:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--surface2);
}

.hakedis-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s;
}
.hakedis-table tbody tr:hover td { background-color: var(--surface2); }
.hakedis-table tbody tr:last-child { border-bottom: none; }

.hakedis-table td {
  padding: 14px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

/* Editlenebilir hücre */
.cell-input {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
  padding: 6px;
  border-radius: 6px;
  outline: none;
  min-width: 90px;
  transition: all 0.2s;
}
.cell-input:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--surface2);
}
.cell-input.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.cell-input.total   { color: var(--primary); font-weight: 600; }

/* Satır silme butonu */
.td-actions {
  text-align: right;
  width: 100px;
  white-space: nowrap;
  vertical-align: middle;
}
/* Yukarı-Aşağı-Sil butonları yatay dizilim */
.td-actions button {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.2s;
  display: inline-block;
}

/* Oklara boğmamak için yön butonları soluk başlar, üzerine gelince canlanır */
.btn-row-action {
  color: var(--text-muted);
  opacity: 0.4;
}
.hakedis-table tbody tr:hover .btn-row-action {
  opacity: 0.7;
}
.btn-row-action:hover {
  opacity: 1 !important;
  color: var(--primary);
  background-color: var(--surface2);
}

/* Çöp Kutusu */
.btn-delete-row {
  color: var(--danger);
  opacity: 0.4;
}
.hakedis-table tbody tr:hover .btn-delete-row {
  opacity: 0.8;
}
.btn-delete-row:hover {
  opacity: 1 !important;
  background-color: rgba(239, 68, 68, 0.1);
  transform: scale(1.1);
}

/* Tfoot — Toplam satırı */
.hakedis-table tfoot tr { background: var(--surface2); }
.hakedis-table tfoot td {
  padding: 14px 16px;
  font-weight: 700;
  font-size: .92rem;
  border-top: 2px solid var(--border);
  color: var(--primary);
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.96);
}
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.prompt-textarea:disabled { opacity: 0.7; cursor: not-allowed; }

/* ---- PROGRESS BAR ---- */
.progress-container {
  margin-top: 16px;
  background: var(--surface2);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}
.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 4px;
  overflow: hidden;
}
[data-theme="light"] .progress-bar-bg {
  background: rgba(0,0,0,0.1);
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 4px;
  transition: width 0.4s ease-out;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
}

.btn-primary  { 
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 140, 0, 0.25);
}
.btn-primary:hover:not(:disabled) { 
  box-shadow: 0 6px 16px rgba(255, 140, 0, 0.4);
  filter: brightness(1.1);
}
.btn-primary:disabled {
  background: var(--border);
  color: var(--text-muted);
  box-shadow: none;
}

.btn-success  { 
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}
.btn-success:hover:not(:disabled) { 
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35); 
  filter: brightness(1.1); 
}

.btn-danger { 
  background-color: var(--danger); 
  color: #fff; 
}
.btn-danger:hover:not(:disabled) { 
  filter: brightness(1.1); 
}

.btn-outline  { 
  background: transparent; 
  color: var(--text); 
  border: 1px solid var(--border); 
}
.btn-outline:hover:not(:disabled) { 
  background: var(--surface2);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost    { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { color: var(--text); }

.btn-full { width: 100%; }
.btn-lg   { padding: 12px 24px; font-size: .95rem; }

/* ---- ALERTS ---- */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .87rem;
  margin-top: 12px;
}
.alert-error { background: rgba(231,76,60,.12); color: #e74c3c; border: 1px solid rgba(231,76,60,.3); }
.hidden { display: none !important; }

/* ---- LOADER ---- */
.loader {
  width: 16px; height: 16px;
  border: 2px solid rgba(17,17,17,.3);
  border-top-color: #111;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---- ÜST MENÜ (Top Nav) ---- */
.top-nav {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 900;
  flex-shrink: 0;
}

.top-nav .nav-left, .top-nav .nav-right {
  display: flex;
  align-items: center;
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 950; /* Below sidebar (1000), above content */
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}
.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ---- PRINT HEADER ---- */
.print-header { display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .main { padding: 12px; }
  .prompt-card { padding: 20px; }
  .table-toolbar { flex-direction: column; align-items: flex-start; }
  .title-input { width: 100%; }
}

/* ============================================================
   PRINT / PDF
   ============================================================ */
@media print {
  :root, html, body {
    --bg-dark: #F3F4F6 !important;
    --bg-panel: #FFFFFF !important;
    --primary: #F97316 !important;
    --text: #111827 !important;
    --text-muted: #4B5563 !important;
    --border: #D1D5DB !important;
    --bg: #FFFFFF !important;
    --surface: #FFFFFF !important;
    --surface2: #FFFFFF !important;
    color: #000 !important;
    background: #fff !important;
  }

  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color: #000 !important; }

  body, html { display: block !important; height: auto !important; font-size: 11pt; }
  
  .sidebar, .sidebar-overlay, .top-nav, .table-toolbar, #btn-add-row, .btn-delete-row,
  .td-actions, #save-status, .alert, #screen-prompt { display: none !important; }

  .main { padding: 0 !important; display: block !important; overflow: visible !important; height: auto !important; }
  #screen-table { display: block !important; }
  #screen-admin, #screen-prompt { display: none !important; }

  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #000;
    padding-bottom: 12px;
  }
  .print-header h1 { font-size: 18pt; margin-bottom: 4px; text-transform: uppercase; }
  .print-header p  { font-size: 10pt; color: #333; }

  .table-wrapper { border: none !important; box-shadow: none !important; overflow: visible !important; }

  .hakedis-table { font-size: 10pt; border-collapse: collapse; width: 100%; }
  .hakedis-table th, .hakedis-table td { 
    border: 1px solid #999 !important; 
    padding: 6px 8px !important; 
    color: #000 !important; 
    background: transparent !important;
    white-space: normal !important;
    word-break: break-word !important;
  }
  .hakedis-table thead { background: #f0f0f0 !important; }
  .hakedis-table tfoot td { background: #f0f0f0 !important; font-weight: 700; }
  .cell-input { padding: 0 !important; background: transparent !important; box-shadow: none !important; color: #000 !important; }
  .hakedis-table tfoot td { color: #000 !important; }
}

/* =========================================================
   AUTH MODAL & ADMIN PANEL
   ========================================================= */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  position: relative;
  background: var(--bg);
  padding: 32px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: translateY(0) scale(1);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.hidden .modal-content {
  transform: translateY(20px) scale(0.95);
}

.history-item {
  background: var(--bg-hover);
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.history-item:hover {
  background: var(--border);
  border-color: var(--accent);
}
