/* ═══════════════════════════════════════════════
   FinancialERP Web — Professional ERP Theme
   ═══════════════════════════════════════════════ */

:root {
    --sidebar-w: 240px;
    --sidebar-bg: #111827;
    --sidebar-border: #1f2937;
    --sidebar-text: #9ca3af;
    --sidebar-hover: #1f2937;
    --sidebar-active-bg: #1d4ed8;
    --sidebar-active-text: #ffffff;
    --sidebar-group: #4b5563;

    --topbar-h: 0px;
    --accent: #1d4ed8;
    --accent-hover: #1e40af;
    --accent-light: #eff6ff;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --red: #dc2626;
    --green: #16a34a;
    --blue: #2563eb;
    --yellow: #d97706;
    --purple: #7c3aed;
    --cyan: #0891b2;
    --orange: #ea580c;
}

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

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13.5px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    -webkit-font-smoothing: antialiased;
}

/* ══ LAYOUT ══════════════════════════════════════ */
.page {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    position: sticky;
    top: 0;
    height: 100vh;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 200;
    border-right: 1px solid var(--sidebar-border);
    transition: transform 0.25s ease;
}

main {
    flex: 1;
    min-height: 100vh;
    background: var(--bg);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.content {
    padding: 0.875rem 1.1rem;
    flex: 1;
    min-width: 0;
}

/* ══ SIDEBAR HEADER ══════════════════════════════ */
.top-row {
    background: #0a0f1e !important;
    border-bottom: 1px solid var(--sidebar-border) !important;
    padding: 0.9rem 1rem !important;
    flex-shrink: 0;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
}

.top-row .container-fluid,
.top-row .navbar-collapse,
.top-row .navbar-toggler { display: contents !important; }

.top-row .navbar-brand {
    color: #f9fafb !important;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.2px;
    line-height: 1.2;
    text-decoration: none;
}

.navbar-toggler { display: none !important; }

/* ══ NAV MENU ════════════════════════════════════ */
.nav-scrollable {
    flex: 1;
    padding: 0.75rem 0 1rem;
}

.nav-scrollable .nav {
    gap: 1px;
    padding: 0 0.75rem;
}

.nav-item { padding: 0 !important; }

.nav-group-label {
    padding: 0.875rem 0.75rem 0.3rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--sidebar-group);
}

.nav-link {
    color: var(--sidebar-text) !important;
    border-radius: 7px;
    padding: 0.5rem 0.875rem !important;
    font-size: 0.83rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    white-space: nowrap;
}

.nav-link .nav-icon {
    font-size: 0.95rem;
    opacity: 0.75;
    width: 18px;
    text-align: center;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #e5e7eb !important;
}

.nav-link.active {
    background: var(--sidebar-active-bg) !important;
    color: var(--sidebar-active-text) !important;
    font-weight: 600;
}

.nav-link.active .nav-icon { opacity: 1; }

/* ══ PAGE HEADER ════════════════════════════════= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-header h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0;
}

/* ══ KPI CARDS ══════════════════════════════════= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 1.1rem 1.25rem;
    transition: box-shadow 0.15s, transform 0.15s;
}

.kpi-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
    transform: translateY(-1px);
}

.kpi-card .kpi-icon {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    display: block;
}

.kpi-card .kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.3rem;
}

.kpi-card .kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ══ FILTER BAR ══════════════════════════════════ */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.875rem;
    margin-bottom: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: flex-end;
}

.filter-bar label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
    display: block;
}

.filter-bar .form-control,
.filter-bar .form-select {
    font-size: 0.83rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f8fafc;
    color: var(--text);
    padding: 0.35rem 0.65rem;
    height: 32px;
}

.filter-bar .form-control:focus,
.filter-bar .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29,78,216,.1);
    background: #fff;
    outline: none;
}

/* ══ TABLE ═══════════════════════════════════════ */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.table-toolbar .record-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.table {
    margin-bottom: 0;
    font-size: 0.82rem;
    width: 100%;
}

.table thead th {
    background: #1e293b;
    color: #cbd5e1;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.6rem 0.8rem;
    white-space: nowrap;
    border: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table tbody td {
    padding: 0.4rem 0.8rem;
    vertical-align: middle;
    border-color: #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
}

.table tbody tr:hover { background: #f0f7ff !important; }
.table tbody tr:nth-child(even) { background: #fafbfd; }

.table tfoot td {
    padding: 0.55rem 0.8rem;
    font-weight: 700;
    background: #1e293b;
    color: #fff;
    border: none;
}

/* ══ BADGES ══════════════════════════════════════ */
.badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
}

/* ══ BUTTONS ══════════════════════════════════════ */
.btn {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.12s;
}

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-sm { padding: 0.25rem 0.65rem; font-size: 0.77rem; }
.btn-outline-secondary { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-outline-secondary:hover { background: #f1f5f9; }
.btn-outline-primary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent-light); }

/* ══ ALERT BOX ═══════════════════════════════════ */
.alert-box {
    padding: 0.625rem 1rem;
    border-radius: 8px;
    font-size: 0.82rem;
    margin-bottom: 0.75rem;
    border: 1px solid;
}
.alert-error { background: #fef2f2; color: #7f1d1d; border-color: #fca5a5; }
.alert-warn  { background: #fffbeb; color: #78350f; border-color: #fde68a; }

/* ══ SUMMARY BADGES ROW ══════════════════════════ */
.summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.625rem;
}

.summary-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid;
}

.chip-blue   { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.chip-green  { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.chip-red    { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.chip-yellow { background: #fffbeb; color: #d97706; border-color: #fde68a; }
.chip-purple { background: #faf5ff; color: #7c3aed; border-color: #e9d5ff; }
.chip-gray   { background: #f8fafc; color: #475569; border-color: #e2e8f0; }

/* ══ PAGINATION ══════════════════════════════════ */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.25rem;
    margin-bottom: 0.5rem;
}

/* ══ SECTION CARD ════════════════════════════════ */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.section-card-header {
    padding: 0.75rem 1.1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.section-card-body { padding: 1.1rem; }

/* ══ LOADING / EMPTY ════════════════════════════= */
.loading-box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    color: var(--text-light);
    font-size: 0.9rem;
    gap: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 2rem; margin-bottom: 0.5rem; display: block; }
.empty-state p { margin: 0; font-weight: 500; }
.empty-state small { color: var(--text-light); font-size: 0.78rem; }

/* ══ STATUS COLORS ═══════════════════════════════ */
.text-debit   { color: var(--red) !important; }
.text-credit  { color: var(--green) !important; }

/* ══ MIZAN TABLE COLORS ══════════════════════════ */
.col-acilis  { background: #eff6ff !important; }
.col-donem   { background: #f0fdf4 !important; }
.col-kapanis { background: #fff7ed !important; }
.col-acilis-h  { background: #1e3a5f; color: #bfdbfe; }
.col-donem-h   { background: #14532d; color: #bbf7d0; }
.col-kapanis-h { background: #7c2d12; color: #fed7aa; }

/* ══ BLAZOR ERROR ════════════════════════════════ */
#blazor-error-ui {
    background: #fef2f2;
    border-top: 2px solid #fca5a5;
    color: #7f1d1d;
    padding: 0.6rem 1.25rem;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    font-size: 0.82rem;
    display: none;
    z-index: 1000;
}
#blazor-error-ui .reload { color: var(--accent); margin-left: 8px; font-weight: 600; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }
.blazor-error-boundary { display: none; }

/* ══ SCROLLBAR ═══════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ══ TAB STYLES ══════════════════════════════════ */
.erp-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.25rem;
}

.erp-tab {
    padding: 0.5rem 1.1rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.12s, border-color 0.12s;
    user-select: none;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.erp-tab:hover { color: var(--accent); }
.erp-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ══ FORM CONTROL (genel) ════════════════════════ */
.form-control, .form-select {
    font-size: 0.83rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29,78,216,.1);
    outline: none;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* ══ MOBILE TOPBAR ══════════════════════════════ */
.mobile-topbar {
    display: none;
    background: var(--sidebar-bg);
    padding: 0 0.875rem;
    height: 44px;
    align-items: center;
    gap: 0.625rem;
    position: sticky;
    top: 0;
    z-index: 300;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.mobile-brand {
    font-size: 0.9rem;
    font-weight: 700;
    color: #f9fafb;
    letter-spacing: -0.2px;
}

.hamburger-btn {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}

.hamburger-btn:hover { background: #1f2937; color: white; }

.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 350;
    cursor: pointer;
}

/* ══ PAGINATION ═════════════════════════════════ */
.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 0.75rem;
}

.pager .pager-info {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ══ PROGRESS ═══════════════════════════════════ */
.progress {
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
    height: 12px;
}

.progress-bar {
    height: 100%;
    background: var(--green);
    font-size: 0.68rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    transition: width 0.4s ease;
}

/* ══ MOBILE BOTTOM NAV ══════════════════════════ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #111827;
    border-top: 1px solid #1f2937;
    z-index: 500;
    height: 58px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-direction: row;
    align-items: stretch;
    padding: 0 2px;
    gap: 1px;
}

.mobile-bottom-nav::-webkit-scrollbar { display: none; }

.mob-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 54px;
    padding: 5px 6px 4px;
    color: #9ca3af !important;
    text-decoration: none !important;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
    gap: 2px;
}

.mob-icon {
    font-size: 1.15rem;
    line-height: 1;
}

.mob-label {
    font-size: 0.56rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    opacity: 0.7;
    white-space: nowrap;
}

.mob-btn:hover {
    background: #1f2937;
    color: #e5e7eb !important;
}

.mob-btn.active {
    color: #60a5fa !important;
    background: rgba(30,58,138,0.5);
}

.mob-btn.active .mob-label { opacity: 1; }

/* ══ RESPONSIVE — TABLET + MOBILE ═══════════════ */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        transform: translateX(-100%);
        z-index: 400;
    }

    .sidebar.nav-open {
        transform: translateX(0);
        box-shadow: 6px 0 32px rgba(0,0,0,0.5);
    }

    main {
        width: 100%;
    }

    .mobile-topbar {
        display: flex;
    }

    .content {
        padding: 0.75rem;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.625rem;
    }

    .filter-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }
}

/* ══ LANDSCAPE / TABLET (641–1024px) ══════════════ */
@media (min-width: 641px) and (max-width: 1024px) {
    .content { padding: 0.875rem 1rem; }
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ══ PORTRAIT PHONES (≤640px) ═════════════════════ */
@media (max-width: 640px) {
    /* Hide hamburger — bottom nav takes over */
    .hamburger-btn { display: none !important; }
    .mobile-topbar { justify-content: center; gap: 0; }

    /* Show bottom nav */
    .mobile-bottom-nav { display: flex; }

    /* Content bottom padding so nothing hides behind bottom nav */
    .content {
        padding: 0.625rem 0.625rem calc(58px + 0.625rem);
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
        padding: 0.5rem 0.625rem;
    }

    .filter-bar > div { width: 100%; }

    .filter-bar .form-control,
    .filter-bar .form-select {
        width: 100% !important;
        height: 36px;
    }

    .filter-bar .d-flex { flex-wrap: wrap; gap: 0.4rem; }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        margin-bottom: 0.875rem;
    }

    .kpi-card { padding: 0.75rem; }
    .kpi-card .kpi-value { font-size: 1.3rem; }
    .kpi-card .kpi-icon { font-size: 1.1rem; margin-bottom: 0.25rem; }

    .summary-row { gap: 0.3rem; }
    .summary-chip { font-size: 0.72rem; padding: 3px 9px; }

    .page-header { margin-bottom: 0.5rem; padding-bottom: 0.375rem; }
    .page-header h4 { font-size: 0.95rem; }

    .table { font-size: 0.72rem !important; }
    .table thead th { font-size: 0.62rem !important; padding: 0.3rem 0.4rem !important; }
    .table tbody td { padding: 0.25rem 0.4rem !important; }
    .table tfoot td { padding: 0.35rem 0.4rem !important; font-size: 0.72rem; }

    .pager { flex-direction: column; gap: 0.4rem; align-items: flex-start; }

    .loading-box { padding: 1.5rem; }
    .empty-state { padding: 1.5rem 0.5rem; }
}
