@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
@import url("https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css");
@import url("graph.css");

:root {
    --font-family: 'Inter', sans-serif;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 80px;
    --bg-color: #111827;
    --sidebar-bg: #1f2937;
    --card-bg: #1f2937;
    --text-color: #f9fafb;
    --text-light: #9ca3af;
    --border-color: #374151;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --green-color: #22c55e;
    --red-color: #ef4444;
    --purple-color: #8b5cf6;
    --yellow-color: #facc15;
    --secondary-bg: #374151;
    --secondary-hover: #4b5563;
    --secondary-text: #d1d5db;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --bg-surface: #1f2937;
    --bg-surface-raised: #2a3647;
    --bg-hover: rgba(75, 85, 99, 0.3);
    --text-normal: #e5e7eb;
    --gold-color: #eab308;
}

[data-theme="light"] {
    --bg-color: #f4f7fa;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-color: #1a202c;
    --text-light: #718096;
    --border-color: #e2e8f0;
    --bg-surface: #ffffff;
    --bg-surface-raised: #f8fafc;
    --bg-hover: #f1f5f9;
    --text-normal: #334155;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-family); background-color: var(--bg-color); color: var(--text-color); font-size: 14px; transition: background-color 0.3s, color 0.3s; }
.main-container { display: flex; }
.main-wrapper { margin-left: var(--sidebar-width); width: calc(100% - var(--sidebar-width)); display: flex; flex-direction: column; transition: margin-left 0.3s ease, width 0.3s ease; }
.page-content { padding: 24px; }

.sidebar { width: var(--sidebar-width); height: 100vh; background-color: var(--sidebar-bg); border-right: 1px solid var(--border-color); position: fixed; top: 0; left: 0; display: flex; flex-direction: column; transition: width 0.3s ease; z-index: 1001; }
.sidebar-header { padding: 20px; }
.logo-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text-color); font-size: 24px; font-weight: 700; }
.logo-text { white-space: nowrap; }
.sidebar-nav { flex-grow: 1; padding: 0 20px; list-style: none; }
.sidebar-nav a { display: flex; align-items: center; gap: 16px; padding: 12px; text-decoration: none; color: var(--text-light); font-weight: 500; border-radius: 8px; transition: color 0.2s, background-color 0.2s; white-space: nowrap; }
.sidebar-nav a:hover { color: var(--text-color); background-color: var(--secondary-bg); }
.sidebar-nav a.active { color: #fff; background-color: var(--primary-color); font-weight: 600; }
.sidebar-nav a .material-icons { font-size: 24px; }
.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-color); }
.theme-toggle-btn { background: none; border: none; width: 100%; display: flex; align-items: center; gap: 16px; padding: 12px; color: var(--text-light); cursor: pointer; font-size: 14px; font-family: var(--font-family); border-radius: 8px; }
.theme-toggle-btn:hover { color: var(--text-color); background-color: var(--secondary-bg); }
.user-profile { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; background-color: var(--primary-color); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.user-details { display: flex; flex-direction: column; white-space: nowrap; }
.user-name { font-weight: 600; }
.logout-link { font-size: 12px; color: var(--text-light); text-decoration: none; }
.sidebar-toggle-btn { position: absolute; bottom: 20px; right: -15px; width: 30px; height: 30px; border-radius: 50%; background-color: var(--sidebar-bg); border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-light); }
.sidebar-toggle-btn .material-icons { transition: transform 0.3s ease; }
.sidebar.collapsed { width: var(--sidebar-width-collapsed); }
.sidebar.collapsed .logo-text, .sidebar.collapsed .nav-text, .sidebar.collapsed .user-details, .sidebar.collapsed .theme-toggle-btn .nav-text { display: none; }
.sidebar.collapsed .logo-link, .sidebar.collapsed .sidebar-nav a, .sidebar.collapsed .theme-toggle-btn { justify-content: center; }
.sidebar.collapsed .sidebar-toggle-btn .material-icons { transform: rotate(180deg); }
.main-wrapper.collapsed { margin-left: var(--sidebar-width-collapsed); width: calc(100% - var(--sidebar-width-collapsed)); }

.page-header { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.page-header h2 { font-size: 28px; font-weight: 700; display: flex; align-items: center; gap: 12px; }
.btn-group { display: flex; gap: 8px; }
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.site-selector-wrapper { position: relative; display: inline-flex; background-color: var(--secondary-bg); border-radius: 8px; }
.site-selector-wrapper select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: none;
    background: #3b3f399c;
    color: var(--secondary-text);
    font-weight: 500;
    font-size: 14px;
    padding: 10px 36px 10px 38px;
    cursor: pointer;
}
.dun {
    text-align: center;
}

.site-selector-wrapper img { width: 18px; height: 18px; border-radius: 4px; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.site-selector-wrapper .material-icons { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-light); }

.card { background-color: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: var(--shadow); transition: background-color 0.3s; padding: 24px; }

button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 8px; border: none; font-weight: 500; font-size: 14px; cursor: pointer; transition: background-color 0.2s; }
button.btn-primary { background-color: var(--primary-color); color: #fff; }
button.btn-primary:hover { background-color: var(--primary-hover); }
button.btn-secondary { background-color: var(--secondary-bg); color: var(--secondary-text); }
button.btn-secondary:hover { background-color: var(--secondary-hover); }
.icon-button { background: none; border: none; cursor: pointer; color: var(--text-light); padding: 4px; border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }

.tab-container { width: 100%; margin-top: 24px; }
.tab-nav { display: flex; position: relative; border-bottom: 1px solid var(--border-color); }
.tab-btn { flex: 1; padding: 14px 16px; border: none; background-color: transparent; color: var(--text-light); font-size: 1rem; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; border-bottom: 3px solid transparent; position: relative; bottom: -1px; transition: all 0.25s ease-out; }
.tab-btn:hover { background-color: var(--bg-hover); color: var(--text-normal); }
.tab-btn.active { color: var(--gold-color); background-color: var(--bg-surface-raised); border-bottom-color: var(--gold-color); }
.tab-nav + .card { border-top-left-radius: 0; border-top-right-radius: 0; padding: 0; }
.tab-content { padding: 24px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.5s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; min-width: 800px; display: table; border-collapse: collapse; font-size: 14px; }
.data-table-head { display: table-header-group; }
.data-table-body { display: table-row-group; }
.data-table-row { display: table-row; border-bottom: 1px solid var(--border-color); transition: background-color 0.2s; }
.data-table-body .data-table-row:hover { background-color: color-mix(in srgb, var(--secondary-bg) 50%, transparent); }
.data-table-head .data-table-row { font-size: 12px; font-weight: 600; color: var(--text-light); text-transform: uppercase; }
.data-table-cell { display: table-cell; padding: 12px 10px; white-space: nowrap; vertical-align: middle; }
.data-table-cell.select-cell { width: 40px; }
.data-table-cell.row-number-cell { width: 40px; color: var(--text-light); }
.data-table-cell.keyword-cell { text-align: left; width: 40%; }
.data-table-cell.keywords { text-align: left; width: 100%; }
.data-table-cell.rank-cell { width: 60px; }
.data-table-cell.change-d, .data-table-cell.change-w, .data-table-cell.change-m { width: 55px; }
.data-table-cell.best-rank-cell { width: 70px; }
.data-table-cell.graph-cell { width: 120px; }
.data-table-cell.action-cell { width: 70px; }
.data-table-cell.keyword-cell, .data-table-cell.rank-cell, .data-table-cell.best-rank-cell { font-weight: 500; font-size: 15px; }
.change-indicator { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.change-indicator .material-icons { font-size: 16px; }
.change-indicator.up { color: var(--green-color); }
.change-indicator.down { color: var(--red-color); }
.change-indicator.neutral { color: var(--text-light); }
.fi { width: 1.2em; height: 0.9em; vertical-align: middle; margin-right: 8px; }
.best-rank-cell .material-icons { font-size: 18px; vertical-align: middle; margin-right: 4px; color: #facc15; }
.icon-button .material-icons { color: var(--primary-color); }

.query-overlay, .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; z-index: 3000; }
.query-overlay.active, .modal-overlay.active { display: flex; }
.loader-box { background-color: rgba(0,0,0,0.3); padding: 30px 40px; border-radius: 12px; color: #fff; text-align: center; }
.loader { width: 60px; height: 60px; border: 5px solid #fff; border-bottom-color: var(--primary-color); border-radius: 50%; display: inline-block; animation: rotation 1s linear infinite; }
@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.modal-container { background: var(--card-bg); border-radius: 12px; width: 90%; max-width: 1000px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; background-color: var(--sidebar-bg); border-bottom: 1px solid var(--border-color); }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-body { flex-grow: 1; overflow-y: auto; }
.modal-footer { padding: 16px 24px; text-align: right; border-top: 1px solid var(--border-color); }

.widget-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; margin-bottom: 32px; }
.widget-card .card-header { font-size: 16px; color: var(--text-light); text-transform: uppercase; }
.widget-content { padding-top: 16px; }
.doughnut-widget { display: flex; align-items: center; gap: 24px; }
.doughnut-chart-container { position: relative; height: 140px; width: 140px; }
.doughnut-legend { display: flex; flex-direction: column; gap: 12px; font-size: 14px; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-item .dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.green { background-color: var(--green-color); }
.dot.yellow { background-color: var(--yellow-color); }
.dot.blue { background-color: var(--primary-color); }
.dot.purple { background-color: var(--purple-color); }
.changes-widget { display: flex; justify-content: space-around; text-align: center; }
.change-item .change-value { font-size: 36px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; }
.change-item .change-value.up { color: var(--green-color); }
.change-item .change-value.down { color: var(--red-color); }
.change-item .change-label { font-size: 14px; color: var(--text-light); }
.progress-bar-container { margin: 20px 0; }
.progress-bar { width: 100%; background-color: var(--red-color); height: 8px; border-radius: 4px; overflow: hidden; }
.progress-risen { height: 100%; background-color: var(--green-color); border-radius: 4px; }
.stable-keywords { text-align: center; color: var(--text-light); display: flex; align-items: center; justify-content: center; gap: 8px; }
.average-widget { display: flex; flex-direction: column; gap: 16px; }
.avg-item { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; font-size: 14px; }
.avg-label { display: flex; align-items: center; gap: 8px; color: var(--text-light); }
.avg-value { font-weight: 600; }
.avg-value small { color: var(--text-light); font-weight: 400; }
.stat-change { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-weight: 600; }
.stat-change.up { color: var(--green-color); }
.stat-change.down { color: var(--red-color); }
.stat-change.neutral { color: var(--text-light); }

.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.form-group label { font-weight: 500; color: var(--text-light); font-size: 14px; }
input[type="text"], input[type="password"], input[type="email"], select { width: 100%; padding: 12px 14px; border: 1px solid var(--border-color); border-radius: 8px; font-family: var(--font-family); font-size: 14px; background-color: var(--bg-color); color: var(--text-color); transition: border-color 0.2s, box-shadow 0.2s; }
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, select:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 20%, transparent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.alert { padding: 1rem; margin-bottom: 1.5rem; border-radius: 0.5rem; font-weight: 500; border: 1px solid transparent; }
.alert-success { background-color: color-mix(in srgb, var(--green-color) 15%, transparent); border-color: color-mix(in srgb, var(--green-color) 30%, transparent); color: var(--green-color); }
.alert-danger, .alert-error { background-color: color-mix(in srgb, var(--red-color) 15%, transparent); border-color: color-mix(in srgb, var(--red-color) 30%, transparent); color: var(--red-color); }

.auth-page-wrapper { display: flex; align-items: center; justify-content: center; width: 100%; flex-grow: 1; }
.auth-container { width: 100%; max-width: 420px; padding: 40px; background-color: var(--card-bg); border-radius: 12px; box-shadow: var(--shadow); text-align: center; }
.auth-container h2 { font-size: 28px; font-weight: 700; margin-bottom: 24px; color: var(--text-color); }
.auth-switch { margin-top: 24px; color: var(--text-light); }
.auth-switch a { color: var(--primary-color); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

.strank { color: #ffa500; }

.tarih-sec {
  display: flex;
  align-items: center;
  background-color: var(--input-bg);
  border-radius: 8px;
  padding: 0 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tarih-sec:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-color-light);
}

.tarih-sec .material-icons {
  color: var(--text-light);
  margin-right: 8px;
  font-size: 20px;
}

.tarih-sec .flatpickr-input {
  border: none;
  background: transparent;
  outline: none;
  box-shadow: none;
  padding: 10px 0;
  font-size: 14px;
  color: var(--text-color);
  width: 110px;
  cursor: pointer;
}


::-webkit-scrollbar { width: 8px; background: var(--sidebar-bg); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-color); }