/* =====================================================
   VIZZI ENTERPRISE PRO — Design System
   ===================================================== */

:root {
    --bg-deep: #0b0f1e;
    --bg-card: rgba(255, 255, 255, 0.04);
    --primary: #8b5cf6;
    --primary-light: #a78bfa;
    --secondary: #3b82f6;
    --accent: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #f1f5f9;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.08);
    --sidebar-w: 250px;
    --ease: all 0.25s cubic-bezier(.4,0,.2,1);
}

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

html, body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg-deep);
    color: var(--text-main);
    font-size: 15px;
}

body {
    background-image:
        radial-gradient(circle at 10% 15%, rgba(139,92,246,0.12) 0%, transparent 40%),
        radial-gradient(circle at 90% 85%, rgba(59,130,246,0.08) 0%, transparent 40%);
}

/* =====================================================
   GLASS UTILITY
   ===================================================== */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border);
    border-radius: 20px;
}

/* =====================================================
   LAYOUT
   ===================================================== */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
    width: 100%;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(255,255,255,0.03);
    border-right: 1px solid var(--border);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 6px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.logo-icon-box {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    flex-shrink: 0;
}

.logo-text-box h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    line-height: 1;
}

.logo-text-box small {
    font-size: 0.62rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--ease);
    white-space: nowrap;
}

.nav-item i {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(139,92,246,0.15);
    color: var(--primary-light);
    border-left: 3px solid var(--primary);
    padding-left: 11px;
}

.sidebar-spacer { flex: 1; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.user-details p { font-size: 0.82rem; font-weight: 600; }
.user-details span { font-size: 0.68rem; color: var(--text-muted); }

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* =====================================================
   TOPBAR
   ===================================================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.01);
    flex-shrink: 0;
}

.page-info h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.45rem;
    font-weight: 700;
}

.page-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

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

.clock-badge {
    font-family: monospace;
    font-size: 1rem;
    background: rgba(0,0,0,0.25);
    padding: 7px 14px;
    border-radius: 9px;
    color: var(--primary-light);
    letter-spacing: 1px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ease);
}

.icon-btn:hover {
    color: var(--text-main);
    background: rgba(255,255,255,0.07);
}

/* =====================================================
   CONTENT AREA (scrollable)
   ===================================================== */
.content-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 28px;
}

/* =====================================================
   SECTIONS
   ===================================================== */
.section-view {
    display: none;
}

.section-view.active {
    display: block;
    animation: fadeUp 0.35s ease;
}

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

/* =====================================================
   STATS GRID
   ===================================================== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-radius: 16px;
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-4px); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.c-purple { background: rgba(139,92,246,0.18); color: #a78bfa; }
.stat-icon.c-green  { background: rgba(16,185,129,0.18);  color: #34d399; }
.stat-icon.c-orange { background: rgba(245,158,11,0.18);  color: #fbbf24; }

.stat-text label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-text h3 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

/* =====================================================
   DASHBOARD GRID (chart + scanner)
   ===================================================== */
.dash-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 16px;
    align-items: start;
}

.chart-card, .scanner-card {
    padding: 22px;
    border-radius: 18px;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--primary-light); }

.chart-wrap {
    position: relative;
    height: 260px;
}

/* =====================================================
   RECORDS SECTION
   ===================================================== */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input-wrap {
    flex: 1;
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 16px;
}

.search-input-wrap input {
    background: none;
    border: none;
    color: var(--text-main);
    width: 100%;
    outline: none;
    font-size: 0.88rem;
}

.search-input-wrap i { color: var(--text-muted); font-size: 0.85rem; }

.filter-select, .export-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 14px;
    border-radius: 11px;
    outline: none;
    cursor: pointer;
    font-size: 0.84rem;
    font-family: 'Inter', sans-serif;
    transition: var(--ease);
}

.export-btn:hover {
    background: rgba(139,92,246,0.18);
    border-color: var(--primary);
}

.table-wrap {
    border-radius: 16px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 540px;
}

thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 14px 16px;
    font-size: 0.86rem;
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover { background: rgba(255,255,255,0.03); }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge.pending  { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge.done     { background: rgba(16,185,129,0.15); color: #34d399; }

/* =====================================================
   MODAL
   ===================================================== */
.modal-bg {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-bg.open { display: flex; }

.modal-box {
    width: 100%;
    max-width: 480px;
    background: #131929;
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 28px;
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.modal-head h2 { font-size: 1.05rem; font-weight: 700; }

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.close-btn:hover { color: var(--danger); }

.device-chip {
    background: rgba(139,92,246,0.12);
    border: 1px solid rgba(139,92,246,0.25);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-weight: 600;
    text-align: center;
    color: var(--primary-light);
    font-size: 0.95rem;
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 10px;
}

.diag-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-bottom: 18px;
}

.diag-btn {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 11px;
    border-radius: 11px;
    cursor: pointer;
    font-size: 0.84rem;
    font-family: 'Inter', sans-serif;
    transition: var(--ease);
}

.diag-btn:hover { background: rgba(255,255,255,0.08); }
.diag-btn.sel   { background: var(--primary); border-color: var(--primary-light); }

.ai-box {
    background: rgba(255,255,255,0.02);
    border-left: 3px solid var(--primary);
    border-radius: 0 10px 10px 0;
    padding: 14px;
    margin-bottom: 18px;
}

.ai-box-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

#modal-ai-text {
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.note-ta {
    width: 100%;
    height: 90px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text-main);
    padding: 12px;
    font-size: 0.84rem;
    font-family: 'Inter', sans-serif;
    resize: none;
    outline: none;
    margin-top: 10px;
    margin-bottom: 18px;
}

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

.btn-save {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 12px;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-save:hover { filter: brightness(1.12); }

/* =====================================================
   CHAT SECTION
   ===================================================== */
.chat-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    max-height: 680px;
    border-radius: 18px;
    overflow: hidden;
}

.chat-feed {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.msg { display: flex; }
.msg.bot  { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }

.bubble {
    max-width: 76%;
    padding: 11px 16px;
    border-radius: 18px;
    font-size: 0.87rem;
    line-height: 1.5;
}

.msg.bot  .bubble { background: rgba(255,255,255,0.06); border: 1px solid var(--border); }
.msg.user .bubble { background: var(--primary); }

.chat-bar {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.15);
}

.chat-bar input {
    flex: 1;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-main);
    font-size: 0.87rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.chat-bar input:focus { border-color: var(--primary); }

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.2s;
}

.send-btn:hover { filter: brightness(1.15); }

/* =====================================================
   SETTINGS
   ===================================================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.settings-card {
    padding: 24px;
    border-radius: 18px;
}

.settings-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.settings-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 18px;
    line-height: 1.5;
}

.danger-btn {
    padding: 10px 18px;
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    color: #f87171;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.84rem;
    font-family: 'Inter', sans-serif;
    transition: var(--ease);
}

.danger-btn:hover {
    background: rgba(239,68,68,0.22);
}

/* =====================================================
   ACTION BUTTON (table)
   ===================================================== */
.action-btn {
    padding: 5px 13px;
    background: rgba(139,92,246,0.12);
    border: 1px solid rgba(139,92,246,0.25);
    color: var(--primary-light);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: 'Inter', sans-serif;
    transition: var(--ease);
}

.action-btn:hover { background: rgba(139,92,246,0.22); }

/* =====================================================
   TOASTS
   ===================================================== */
#toast-zone {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    border-radius: 12px;
    background: #1a2035;
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    font-size: 0.84rem;
    pointer-events: all;
    animation: slideIn 0.3s ease;
    transition: opacity 0.4s;
}

@keyframes slideIn { from { transform: translateX(80px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.toast-item.t-success { border-left: 3px solid var(--accent); }
.toast-item.t-info    { border-left: 3px solid var(--primary); }
.toast-item.t-danger  { border-left: 3px solid var(--danger); }

/* =====================================================
   QR READER
   ===================================================== */
#reader { border: none !important; border-radius: 14px; overflow: hidden; }
#reader button {
    background: var(--primary) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 9px !important;
    padding: 8px 16px !important;
    font-family: 'Inter', sans-serif !important;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

/* Tablet: compact sidebar (960px and below) */
@media (max-width: 960px) {
    :root { --sidebar-w: 72px; }

    .logo-text-box,
    .nav-item span,
    .user-details { display: none; }

    .logo-area {
        padding: 10px 0 20px;
        justify-content: center;
    }

    .nav-item {
        justify-content: center;
        padding: 13px 0;
        border-left: none;
    }

    .nav-item.active {
        border-left: none;
        border-right: 3px solid var(--primary);
        padding-right: 0;
    }

    .user-chip { justify-content: center; }
    .dash-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .content-scroll { padding: 18px 16px; }
    .topbar { padding: 16px 18px; }
}

/* Mobile: bottom navigation bar (640px and below) */
@media (max-width: 640px) {

    /* Flip layout: main on top, sidebar as bottom bar */
    .app-wrapper {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    /* Main area takes remaining height above the nav */
    .main-area {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    /* Content scroll has padding at bottom so content doesn't hide behind nav */
    .content-scroll {
        padding: 12px 12px 24px;
        overflow-y: auto;
        flex: 1;
    }

    /* ── Bottom Navigation Bar ── */
    .sidebar {
        width: 100%;
        height: 62px;
        min-height: 62px;
        flex-shrink: 0;
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        padding: 0 8px;
        gap: 0;
        border-right: none;
        border-top: 1px solid var(--border);
        border-radius: 0;
        background: #0d1220;
        overflow: visible;
    }

    /* Hide things not needed in bottom nav */
    .logo-area,
    .sidebar-spacer,
    .user-chip { display: none !important; }

    /* Nav menu: full width, horizontal */
    .nav-menu {
        display: flex !important;
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
    }

    /* Each nav item: icon + tiny label, stacked */
    .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 10px;
        border-radius: 10px;
        border: none !important;
        color: var(--text-muted);
        min-width: 52px;
        font-size: 0;  /* hide text by default */
    }

    /* Show icon */
    .nav-item i {
        font-size: 1.15rem;
        width: auto;
    }

    /* Show short label via ::after */
    .nav-item[data-sec="dashboard"]::after  { content: "Ana Sayfa"; }
    .nav-item[data-sec="records"]::after    { content: "Kayıtlar"; }
    .nav-item[data-sec="chat"]::after       { content: "Vizzi"; }
    .nav-item[data-sec="settings"]::after   { content: "Ayarlar"; }

    .nav-item::after {
        font-size: 0.6rem;
        color: inherit;
        font-family: 'Inter', sans-serif;
    }

    .nav-item.active {
        color: var(--primary-light);
        background: rgba(139,92,246,0.1);
    }

    /* ── Topbar ── */
    .topbar {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
        flex-shrink: 0;
    }

    .page-info h1 { font-size: 1.1rem; }
    .page-info p  { font-size: 0.72rem; }

    .topbar-actions { gap: 8px; }
    .clock-badge { font-size: 0.8rem; padding: 5px 10px; }

    /* ── Stats Row ── */
    .stats-row {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 14px;
    }

    .stat-card { padding: 14px 16px; }
    .stat-text h3 { font-size: 1.6rem; }

    /* ── Dashboard Grid ── */
    .dash-grid { grid-template-columns: 1fr; gap: 12px; }

    .chart-card, .scanner-card {
        padding: 16px;
    }

    .chart-wrap { height: 200px; }

    /* ── Table ── */
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .search-input-wrap { min-width: unset; width: 100%; }
    .filter-select, .export-btn { width: 100%; text-align: center; padding: 10px; }

    /* ── Chat ── */
    .chat-wrap {
        height: 100%;
        max-height: none;
        border-radius: 14px;
    }

    .chat-feed { padding: 14px; }

    /* ── Settings ── */
    .settings-grid { grid-template-columns: 1fr; gap: 12px; }

    /* ── Modal (full screen on mobile) ── */
    .modal-bg { padding: 0; align-items: flex-end; }

    .modal-box {
        max-width: 100%;
        border-radius: 22px 22px 0 0;
        max-height: 92vh;
        overflow-y: auto;
    }

    /* ── Toasts ── */
    #toast-zone {
        bottom: 72px;
        right: 10px;
        left: 10px;
    }
}