/* ===========================================================
   MSE AI OS — Tasarım Sistemi
   Marka: lacivert + altın, Poppins, koyu tema varsayılan,
   cam efekti (glassmorphism) panellerle "Apple tarzı" his.
   =========================================================== */

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

:root {
    --navy-950: #0B1220;
    --navy-900: #101A2E;
    --navy-800: #16223B;
    --navy-700: #1A2B4A;
    --navy-600: #22355C;
    --gold: #F5A623;
    --gold-soft: #F5C365;
    --text-primary: #F4F6FB;
    --text-muted: #9AA8C7;
    --border-soft: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(22, 34, 59, 0.55);
    --glass-border: rgba(255, 255, 255, 0.10);
    --danger: #E5484D;
    --success: #3DD68C;
    --radius-lg: 18px;
    --radius-md: 12px;
    --shadow-soft: 0 20px 50px rgba(4, 8, 20, 0.45);
}

[data-theme="light"] {
    --navy-950: #F4F6FB;
    --navy-900: #FFFFFF;
    --navy-800: #FFFFFF;
    --navy-700: #1A2B4A;
    --text-primary: #17213A;
    --text-muted: #5A6785;
    --border-soft: rgba(23, 33, 58, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(23, 33, 58, 0.08);
    --shadow-soft: 0 20px 50px rgba(23, 33, 58, 0.10);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at 15% -10%, var(--navy-800), var(--navy-950) 55%);
    color: var(--text-primary);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
.muted { color: var(--text-muted); }

.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

/* ---------- Shell / Sidebar ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    flex-shrink: 0;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-soft);
    background: rgba(11, 18, 32, 0.35);
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 24px; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, var(--gold), var(--gold-soft));
    color: var(--navy-950);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; letter-spacing: 0.5px;
}
.brand-mark.lg { width: 64px; height: 64px; font-size: 18px; border-radius: 16px; margin: 0 auto 14px; }
.brand-title { font-weight: 600; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.nav a:hover { background: rgba(245, 166, 35, 0.08); color: var(--text-primary); }
.nav a.active { background: rgba(245, 166, 35, 0.14); color: var(--gold); }

.sidebar-footer { border-top: 1px solid var(--border-soft); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.theme-toggle {
    background: none; border: 1px solid var(--border-soft); color: var(--text-primary);
    border-radius: var(--radius-md); padding: 8px; cursor: pointer; font-size: 13px;
}
.user-chip { font-size: 12px; color: var(--text-muted); }
.logout-link { font-size: 13px; color: var(--danger); font-weight: 500; }

.content { flex: 1; padding: 32px 40px; max-width: 1200px; }

/* ---------- Page header ---------- */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { margin: 0 0 4px; font-size: 26px; font-weight: 700; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { padding: 20px 22px; }
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--gold); }

/* ---------- Panels / grid ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } .content { padding: 20px; } .sidebar { position: relative; height: auto; } .shell { flex-direction: column; } }

.panel { padding: 22px 24px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.list li { padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); }
.list li:last-child { border-bottom: none; padding-bottom: 0; }

.cta-row { margin-top: 8px; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    background: rgba(255,255,255,0.08); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
}
.badge-critical, .badge-high { background: rgba(229, 72, 77, 0.15); color: var(--danger); }
.badge-medium { background: rgba(245, 166, 35, 0.15); color: var(--gold); }
.badge-low { background: rgba(61, 214, 140, 0.15); color: var(--success); }

/* ---------- Forms ---------- */
.form-panel { display: none; }
.form-panel.open { display: block; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid h2 { grid-column: 1 / -1; margin: 10px 0 0; font-size: 14px; color: var(--gold); }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }

input, select, textarea, button {
    font-family: inherit;
}

input, select, textarea {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }

.btn-primary, .btn-secondary {
    border: none; border-radius: var(--radius-md); padding: 11px 20px;
    font-weight: 600; font-size: 14px; cursor: pointer; transition: transform .1s ease, opacity .15s ease;
}
.btn-primary { background: linear-gradient(135deg, var(--gold), var(--gold-soft)); color: var(--navy-950); }
.btn-primary:hover { opacity: 0.92; }
.btn-secondary { background: rgba(255,255,255,0.06); color: var(--text-primary); border: 1px solid var(--border-soft); }
.btn-secondary.small { padding: 6px 12px; font-size: 12px; }
.header-actions { display: flex; gap: 10px; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); }
.table td { padding: 12px; border-bottom: 1px solid var(--border-soft); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.03); }

/* ---------- Auth / Setup pages ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; padding: 40px 34px; text-align: center; }
.auth-card.wide { max-width: 640px; text-align: left; }
.auth-card h1 { margin: 0; font-size: 22px; }
.auth-card form { margin-top: 22px; display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-card label { font-size: 13px; color: var(--text-muted); display: flex; flex-direction: column; gap: 6px; }
.auth-card .btn-primary { margin-top: 6px; }

.alert { padding: 12px 14px; border-radius: var(--radius-md); font-size: 13px; margin: 16px 0; text-align: left; }
.alert.error { background: rgba(229, 72, 77, 0.12); color: var(--danger); border: 1px solid rgba(229, 72, 77, 0.25); }
.alert.success { background: rgba(61, 214, 140, 0.12); color: var(--success); border: 1px solid rgba(61, 214, 140, 0.25); }

/* ---------- Chat ---------- */
.chat-shell { display: flex; flex-direction: column; height: 70vh; padding: 0; overflow: hidden; }
.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 70%; padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.5; }
.msg.assistant .bubble { background: rgba(255,255,255,0.06); border: 1px solid var(--border-soft); border-bottom-left-radius: 4px; }
.msg.user .bubble { background: linear-gradient(135deg, var(--gold), var(--gold-soft)); color: var(--navy-950); border-bottom-right-radius: 4px; }
.bubble .actions { margin-top: 8px; font-size: 11px; opacity: 0.75; }
.composer { display: flex; flex-direction: column; gap: 0; padding: 18px; border-top: 1px solid var(--border-soft); }
.composer-row .btn-primary { align-self: flex-end; }

code { background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 6px; font-size: 12px; }

/* ===========================================================
   MOBİL UYUMLULUK
   =========================================================== */

.mobile-topbar { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 900px) {
    .shell { display: block; }

    /* Üst bar: sadece mobilde görünür */
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        position: sticky;
        top: 0;
        z-index: 40;
        background: rgba(11, 18, 32, 0.85);
        backdrop-filter: blur(14px);
        border-bottom: 1px solid var(--border-soft);
    }
    .mobile-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
    .brand-mark.sm { width: 30px; height: 30px; font-size: 10px; border-radius: 8px; }

    .hamburger {
        width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border-soft);
        background: rgba(255,255,255,0.04); display: flex; flex-direction: column;
        align-items: center; justify-content: center; gap: 4px; cursor: pointer; flex-shrink: 0;
    }
    .hamburger span { width: 18px; height: 2px; background: var(--text-primary); border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
    .hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
    .hamburger.open span:nth-child(2) { opacity: 0; }
    .hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

    /* Sidebar: varsayılan gizli, açıldığında soldan kayan panel */
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 78vw;
        max-width: 300px;
        height: 100vh;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 20px 0 50px rgba(0,0,0,0.4);
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-overlay {
        display: block;
        position: fixed; inset: 0;
        background: rgba(4, 8, 20, 0.55);
        z-index: 50;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }
    .sidebar-overlay.open { opacity: 1; pointer-events: auto; }

    .content { padding: 18px 16px 40px; max-width: 100%; }

    .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .page-header h1 { font-size: 21px; }
    .header-actions { width: 100%; }
    .header-actions .btn-primary, .header-actions .btn-secondary { width: 100%; }

    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .kpi-card { padding: 14px 16px; }
    .kpi-value { font-size: 20px; }

    .grid-2 { grid-template-columns: 1fr; gap: 14px; }

    .form-grid { grid-template-columns: 1fr; }

    /* Tablolar: yatay kaydırma ile taşma engellenir */
    .panel:has(.table) { padding: 0; overflow: hidden; }
    .table-scroll, .panel .table { display: block; }
    .panel .table { overflow-x: auto; white-space: nowrap; }
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr {
        padding: 14px 16px;
        border-bottom: 1px solid var(--border-soft);
        white-space: normal;
    }
    .table td {
        border: none;
        padding: 3px 0;
        white-space: normal;
    }
    .table td::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 110px;
        font-size: 11px;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    /* Chat */
    .chat-shell { height: calc(100vh - 220px); border-radius: 14px; }
    .bubble { max-width: 86%; }
    .composer { flex-direction: column; align-items: stretch; padding: 12px; }
    .composer .btn-primary { align-self: stretch; }

    .auth-card { padding: 30px 22px; }
    .auth-card.wide .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

/* ---------- Chat: görsel ekleme ---------- */
.composer-row { display: flex; gap: 12px; align-items: flex-end; }
.composer-row textarea { flex: 1; resize: none; }

.attach-btn {
    width: 44px; height: 44px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-soft); border-radius: var(--radius-md);
    background: rgba(255,255,255,0.04); cursor: pointer; font-size: 18px;
    transition: background .15s ease;
}
.attach-btn:hover { background: rgba(245, 166, 35, 0.12); }

.image-preview { padding: 0 18px; }
.image-preview.has-image { padding-bottom: 12px; }
.preview-chip {
    position: relative; display: inline-block; margin-top: 10px;
    border-radius: 10px; overflow: hidden; border: 1px solid var(--border-soft);
}
.preview-chip img { display: block; height: 72px; width: auto; }
.preview-chip button {
    position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
    border-radius: 50%; border: none; background: rgba(0,0,0,0.6); color: #fff;
    font-size: 11px; cursor: pointer; line-height: 1;
}

.msg-image {
    display: block; max-width: 100%; width: 260px; height: auto;
    border-radius: 12px; margin-bottom: 8px; cursor: zoom-in;
}

@media (max-width: 900px) {
    .composer { padding: 12px; }
    .composer-row { align-items: center; }
    .attach-btn { width: 40px; height: 40px; }
    .msg-image { width: 100%; max-width: 220px; }
}

/* ---------- Nav bildirim rozeti ---------- */
.nav-badge {
    display: inline-block; margin-left: 6px; padding: 1px 7px;
    border-radius: 999px; background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700; vertical-align: middle;
}

/* ---------- Takvim (ajanda görünümü) ---------- */
.agenda-day { margin-bottom: 18px; }
.agenda-date { font-size: 12px; color: var(--gold); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.agenda-date.is-past { color: var(--danger); }
.agenda-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 14px; }
.agenda-item:last-child { border-bottom: none; }
.agenda-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.agenda-dot.customer { background: var(--gold); }
.agenda-dot.project { background: var(--success); }
.agenda-dot.task { background: #7aa2ff; }
.agenda-dot.purchase_order { background: #c77dff; }

/* ---------- Bildirimler sayfası ---------- */
.notif-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.notif-item:last-child { border-bottom: none; }
.notif-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 15px; }
.notif-icon.critical { background: rgba(229,72,77,0.15); }
.notif-icon.high { background: rgba(245,166,35,0.18); }
.notif-icon.medium { background: rgba(122,162,255,0.15); }

/* ---------- Raporlar ---------- */
.chart-card { padding: 20px; margin-bottom: 20px; }
.chart-card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.chart-wrap { position: relative; height: 280px; }

/* ---------- API token ---------- */
.token-value { font-family: monospace; font-size: 12px; word-break: break-all; background: rgba(255,255,255,0.06); padding: 10px 12px; border-radius: 8px; margin: 8px 0; }

/* ---------- Satır işlemleri (düzenle/sil) ---------- */
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.row-actions form { display: inline; margin: 0; }
.btn-danger {
    border: 1px solid rgba(229,72,77,0.35); border-radius: var(--radius-md);
    background: rgba(229,72,77,0.10); color: var(--danger);
    font-weight: 600; cursor: pointer; transition: background .15s ease;
}
.btn-danger:hover { background: rgba(229,72,77,0.2); }
.btn-danger.small, .btn-secondary.small { padding: 6px 12px; font-size: 12px; }
@media (max-width: 900px) {
    .row-actions { flex-wrap: wrap; }
}

/* ---------- Dashboard görev satırı ---------- */
.task-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
