/* ============================================================
   CRM Pro — Global Stil
   Palet: Mavi (#1a56db) / Beyaz (#ffffff) / Siyah (#111827)
   Font: Inter (Google Fonts)
   ============================================================ */

/* ===== CSS DEĞIŞKENLERI ===== */
:root {
    --primary:        #1a56db;
    --primary-dark:   #1e429f;
    --primary-light:  #ebf0ff;
    --primary-hover:  #1648c8;

    --bg:             #f4f7fe;
    --surface:        #ffffff;
    --surface-alt:    #f8faff;

    --text:           #111827;
    --text-muted:     #6b7280;
    --text-light:     #9ca3af;

    --border:         #e5e7eb;
    --border-focus:   #93c5fd;

    --success:        #059669;
    --success-bg:     #ecfdf5;
    --danger:         #dc2626;
    --danger-bg:      #fef2f2;
    --warning:        #d97706;
    --warning-bg:     #fffbeb;

    /* Durum Renkleri */
    --status-gorusuluyor:    #2563eb;
    --status-gorusuluyor-bg: #eff6ff;
    --status-ciddi:          #7c3aed;
    --status-ciddi-bg:       #f5f3ff;
    --status-satis:          #059669;
    --status-satis-bg:       #ecfdf5;
    --status-ilgisiz:        #dc2626;
    --status-ilgisiz-bg:     #fef2f2;

    --radius-sm:      6px;
    --radius-md:      10px;
    --radius-lg:      16px;
    --radius-xl:      20px;

    --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:      0 4px 16px rgba(0,0,0,.08);
    --shadow-lg:      0 10px 40px rgba(0,0,0,.12);

    --navbar-h:       58px;
    --transition:     0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--navbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon-sm { display: flex; align-items: center; }

.navbar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.navbar-divider {
    color: var(--border);
    font-weight: 300;
}

.navbar-tenant {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.admin-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-email {
    font-size: 12px;
    color: var(--text-muted);
    display: none;
}
@media (min-width: 640px) { .navbar-email { display: block; } }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
@media (min-width: 768px) { .main-content { padding: 28px 24px; } }

/* ============================================================
   DURUM SAYAÇ KARTLARI
   ============================================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (min-width: 640px) { .stats-row { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px;
    height: 100%;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

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

.stat-card.active { border-color: currentColor; }

/* Renk varyasyonları */
.stat-gorusuluyor { --card-color: var(--status-gorusuluyor); }
.stat-gorusuluyor::before { background: var(--status-gorusuluyor); }
.stat-gorusuluyor .stat-icon { color: var(--status-gorusuluyor); background: var(--status-gorusuluyor-bg); }

.stat-ciddi { --card-color: var(--status-ciddi); }
.stat-ciddi::before { background: var(--status-ciddi); }
.stat-ciddi .stat-icon { color: var(--status-ciddi); background: var(--status-ciddi-bg); }

.stat-satis { --card-color: var(--status-satis); }
.stat-satis::before { background: var(--status-satis); }
.stat-satis .stat-icon { color: var(--status-satis); background: var(--status-satis-bg); }

.stat-ilgisiz { --card-color: var(--status-ilgisiz); }
.stat-ilgisiz::before { background: var(--status-ilgisiz); }
.stat-ilgisiz .stat-icon { color: var(--status-ilgisiz); background: var(--status-ilgisiz-bg); }

.stat-primary { --card-color: var(--primary); }
.stat-primary::before { background: var(--primary); }
.stat-primary .stat-icon { color: var(--primary); background: var(--primary-light); }

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info { display: flex; flex-direction: column; gap: 2px; }

.stat-count {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

/* ============================================================
   AI SOHBET KUTUSU
   ============================================================ */
.chat-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border-top: 3px solid var(--primary);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--primary);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.chat-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.chat-box { padding: 16px 20px; }

.chat-textarea {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    resize: vertical;
    min-height: 80px;
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.6;
}

.chat-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
    background: var(--surface);
}

.chat-textarea::placeholder { color: var(--text-light); }

.chat-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.chat-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-chat {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
}

.chat-result {
    margin: 0 20px 16px;
    border-radius: var(--radius-md);
    overflow: hidden;
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-result-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: var(--primary-light);
    border: 1px solid var(--border-focus);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--primary-dark);
    font-weight: 500;
}

.chat-result-inner.error {
    background: var(--danger-bg);
    border-color: #fca5a5;
    color: var(--danger);
}

.chat-result-inner.success {
    background: var(--success-bg);
    border-color: #6ee7b7;
    color: var(--success);
}

/* ============================================================
   LEAD LİSTESİ
   ============================================================ */
.leads-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.leads-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.leads-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.lead-total-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.leads-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Filtre Sekmeleri */
.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.filter-tab {
    padding: 5px 12px;
    border: none;
    background: transparent;
    border-radius: calc(var(--radius-sm) - 1px);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.filter-tab:hover { color: var(--text); background: var(--surface); }

.filter-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Arama Çubuğu */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: transparent;
}

.search-input::placeholder { color: var(--text-light); }

/* Tablo */
.table-wrapper { overflow-x: auto; }

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

.leads-table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    white-space: nowrap;
}

.leads-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: middle;
}

.leads-table tbody tr { transition: background var(--transition); }
.leads-table tbody tr:hover { background: var(--surface-alt); }
.leads-table tbody tr:last-child td { border-bottom: none; }

/* Durum Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.status-gorusuluyor { background: var(--status-gorusuluyor-bg); color: var(--status-gorusuluyor); }
.status-ciddi       { background: var(--status-ciddi-bg);       color: var(--status-ciddi); }
.status-satis_yapildi { background: var(--status-satis-bg);     color: var(--status-satis); }
.status-ilgisiz     { background: var(--status-ilgisiz-bg);     color: var(--status-ilgisiz); }

/* Tablo Loading */
.loading-row td { padding: 40px 16px !important; }

.table-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.7s linear infinite; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    color: var(--text-muted);
    gap: 8px;
}
.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 13px; }

/* ============================================================
   ADMIN PANELİ
   ============================================================ */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}
@media (min-width: 900px) {
    .admin-grid { grid-template-columns: 380px 1fr; }
}

.admin-card, .admin-full-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.admin-form { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.field-hint {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 6px;
}

.field-description {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Son Leadler */
#recentLeadsContainer { padding: 0; }

.recent-lead-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    transition: background var(--transition);
}
.recent-lead-item:last-child { border-bottom: none; }
.recent-lead-item:hover { background: var(--surface-alt); }

.recent-lead-info { flex: 1; min-width: 0; }
.recent-lead-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-lead-tenant { font-size: 11px; color: var(--text-muted); }

.recent-lead-meta { text-align: right; }
.recent-lead-date { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   FORM ELEMANLARİ
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; }

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

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

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

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}

.form-input::placeholder { color: var(--text-light); }

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.input-wrapper { position: relative; }

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}
.toggle-password:hover { color: var(--text); }

/* ============================================================
   BUTONLAR
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(26,86,219,.3);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

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

/* ============================================================
   ALERT / HATA MESAJLARI
   ============================================================ */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #fca5a5;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: #6ee7b7;
}

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

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

.modal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease;
}

.modal-sm { max-width: 380px; }

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 15px; font-weight: 600; color: var(--text); }

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color var(--transition);
    border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text); background: var(--bg); }

.modal-form, .modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}

.lead-detail-row { display: flex; flex-direction: column; gap: 3px; }
.detail-value { font-size: 14px; color: var(--text); font-weight: 500; }

.confirm-text { font-size: 14px; color: var(--text); }
.confirm-warning { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* Sohbet Geçmişi */
.chat-log-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.chat-log-item:last-child { border-bottom: none; }
.chat-log-msg { font-size: 13px; color: var(--text); }
.chat-log-action {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.chat-log-date { font-size: 11px; color: var(--text-light); float: right; }

/* ============================================================
   GİRİŞ SAYFASI
   ============================================================ */
.login-page {
    background: linear-gradient(135deg, #e8f0fe 0%, #f4f7fe 50%, #eef2ff 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 28px;
}

.brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(26,86,219,.25);
}

.brand-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.brand-tagline {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

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

.btn-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.login-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 11px;
    color: var(--text-light);
}

/* ============================================================
   HIGHLIGHT / ANİMASYON (Lead Güncelleme)
   ============================================================ */
@keyframes highlightRow {
    0%   { background: var(--primary-light); }
    100% { background: transparent; }
}

.row-highlight { animation: highlightRow 2s ease forwards; }

/* ============================================================
   NOTES ÖNBAKIM
   ============================================================ */
.notes-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 12px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
    .chat-actions { flex-direction: column; align-items: stretch; }
    .btn-chat { width: 100%; justify-content: center; }
    .form-row { grid-template-columns: 1fr; }
    .filter-tabs { overflow-x: auto; }
    .filter-tab { flex-shrink: 0; }
    .leads-header { flex-direction: column; align-items: flex-start; }
    .leads-header-right { width: 100%; }
    .navbar-divider, .navbar-tenant { display: none; }
}

@media (max-width: 480px) {
    .login-card { padding: 24px 20px; }
    .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-count { font-size: 20px; }
}
