@import url('./icons.css');

html, body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, system-ui, sans-serif;
    background: #F8FAFC;
    color: #0b1c30;
}

#blazor-error-ui {
    background: #ffdad6; color: #93000a; bottom: 0; display: none;
    left: 0; padding: 0.75rem 1rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.km-page { max-width: 80rem; margin-left: auto; margin-right: auto; width: 100%; }

.km-scroll::-webkit-scrollbar { height: 8px; width: 8px; }
.km-scroll::-webkit-scrollbar-track { background: #F8FAFC; }
.km-scroll::-webkit-scrollbar-thumb { background: #E2E8F0; border-radius: 4px; }
.km-scroll::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* ───────── Data grid (matches Docs HTML mockups) ───────── */
.km-card { background:#fff; border:1px solid #E2E8F0; border-radius:.5rem; overflow:hidden; box-shadow:0 1px 2px rgba(0,0,0,.03); }
.km-table { width:100%; text-align:left; border-collapse:collapse; }
.km-table > thead { background:#002046; color:#fff; position:sticky; top:0; z-index:10; }
.km-table > thead th {
    padding:.5rem 1rem; font-size:12px; line-height:16px; font-weight:600; letter-spacing:.05em;
    border-bottom:1px solid rgba(226,232,240,.3); border-right:1px solid rgba(226,232,240,.3); white-space:nowrap;
}
.km-table > thead th:last-child { border-right:none; }
.km-table > tbody tr { height:32px; border-bottom:1px solid #E2E8F0; transition:background-color .12s; }
.km-table > tbody tr:nth-child(even) { background:#F1F5F9; }
.km-table > tbody tr:hover { background:#eff4ff; }
.km-table > tbody td { padding:.25rem 1rem; font-size:12px; line-height:16px; border-right:1px solid #E2E8F0; }
.km-table > tbody td:last-child { border-right:none; }
.km-table .km-mono { font-family:'JetBrains Mono', ui-monospace, monospace; font-size:13px; line-height:20px; font-weight:500; }
.km-table tfoot td { padding:.5rem 1rem; font-weight:600; background:#F8FAFC; border-top:2px solid #002046; }
.km-grid-footer {
    background:#F8FAFC; border-top:1px solid #E2E8F0; padding:.5rem;
    display:flex; justify-content:space-between; align-items:center; font-size:12px; color:#44474e;
}

/* ───────── Status pills ───────── */
.km-pill { padding:.125rem .5rem; border-radius:.25rem; font-size:10px; font-weight:700; white-space:nowrap; }
.km-pill-approved { background:rgba(16,185,129,.1); color:#10B981; }
.km-pill-pending  { background:rgba(245,158,11,.1); color:#F59E0B; }
.km-pill-rejected { background:rgba(239,68,68,.1);  color:#EF4444; }
.km-pill-disbursed{ background:rgba(59,130,246,.1); color:#3B82F6; }
.km-pill-closed   { background:rgba(99,102,241,.1); color:#6366F1; }
.km-pill-neutral  { background:#d3e4fe; color:#44474e; }

/* ───────── Buttons ───────── */
.km-btn { display:inline-flex; align-items:center; justify-content:center; gap:.5rem;
    padding:.5rem 1rem; border-radius:.25rem; font-size:12px; font-weight:600; letter-spacing:.05em;
    cursor:pointer; transition:all .15s; border:1px solid transparent; white-space:nowrap; min-height:38px; }
.km-btn:disabled { opacity:.6; cursor:not-allowed; }
.km-btn-primary { background:#002046; color:#fff; }
.km-btn-primary:hover:not(:disabled) { background:#1b365d; }
.km-btn-outline { background:#fff; color:#002046; border-color:#c4c6cf; }
.km-btn-outline:hover:not(:disabled) { background:#eff4ff; }
.km-btn-success { background:#10B981; color:#fff; }
.km-btn-success:hover:not(:disabled) { background:#059669; }
.km-btn-info { background:#3B82F6; color:#fff; }
.km-btn-info:hover:not(:disabled) { background:#2563eb; }
.km-btn-icon { padding:.375rem; min-height:0; border-radius:9999px; background:transparent; color:#002046; }
.km-btn-icon:hover { background:#eff4ff; }
.km-btn-icon.km-danger { color:#ba1a1a; }
.km-btn-icon.km-danger:hover { background:#ffdad6; }

/* ───────── Search / inputs ───────── */
.km-search { position:relative; }
.km-search > .material-symbols-outlined {
    position:absolute; left:.75rem; top:50%; transform:translateY(-50%);
    color:#74777f; font-size:20px; pointer-events:none;
}
.km-search > input {
    width:100%; padding:.5rem 1rem .5rem 2.5rem; border:1px solid #c4c6cf; border-radius:.25rem;
    font-size:12px; background:#fff; outline:none; transition:box-shadow .15s,border-color .15s;
}
.km-search > input:focus { border-color:#002046; box-shadow:0 0 0 2px rgba(0,32,70,.2); }

/* floating-label field (backwards-compatible with fixes) */
.km-field { position:relative; }
.km-field > label:not(.inline-flex) {
    position:absolute; top:-.5rem; left:.5rem; background:#fff; padding:0 .25rem; z-index:10;
    font-size:10px; font-weight:600; letter-spacing:.05em; color:#002046; pointer-events:none;
}
.km-field > label.km-optional { color:#44474e; font-weight:500; }
.km-field input:not([type="checkbox"]):not([type="radio"]), .km-field select, .km-field textarea {
    width:100%; padding:.65rem .75rem .45rem; border:1.5px solid #cbd5e1; border-radius:.375rem;
    font-size:13px; line-height:20px; background:#fff; color:#0b1c30; outline:none;
    transition:border-color .15s, box-shadow .15s; appearance:auto; box-sizing:border-box;
}
input[type="radio"], input[type="checkbox"] { width:auto; height:auto; position:static; }
.km-field input:focus, .km-field select:focus, .km-field textarea:focus {
    border-color:#002046; box-shadow:0 0 0 3px rgba(0,32,70,.12);
}
.km-field input:disabled, .km-field input[readonly], .km-field select:disabled {
    background:#eff4ff; color:#44474e; cursor:not-allowed;
}
.km-field.km-mono-field input { font-family:'JetBrains Mono', ui-monospace, monospace; font-size:13px; }
.km-req { color:#ba1a1a; }

/* ───────── Modern Standard Form Controls ───────── */
.km-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.km-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #475569;
    margin-bottom: 0.1rem;
}
.km-label .km-req {
    margin-left: 2px;
}
.km-input, .km-select, .km-textarea {
    display: block;
    width: 100%;
    height: 40px;
    padding: 0.5rem 0.75rem;
    font-size: 13px;
    line-height: 1.5;
    color: #0b1c30;
    background-color: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    box-sizing: border-box;
}
.km-textarea {
    height: auto;
    min-height: 72px;
    padding: 0.5rem 0.75rem;
    resize: vertical;
}
.km-input:hover, .km-select:hover, .km-textarea:hover {
    border-color: #94a3b8;
}
.km-input:focus, .km-select:focus, .km-textarea:focus {
    border-color: #002046;
    box-shadow: 0 0 0 3px rgba(0, 32, 70, 0.12);
    background-color: #ffffff;
}
.km-input:disabled, .km-input[readonly], .km-select:disabled {
    background-color: #f1f5f9;
    color: #64748b;
    border-color: #e2e8f0;
    cursor: not-allowed;
}
.km-input-mono {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 500;
}

/* ───────── Card Components ───────── */
.km-card-padded {
    padding: 1.25rem 1.5rem;
}
.km-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FAFBFD;
}
.km-card-body {
    padding: 1.25rem 1.5rem;
}

/* ───────── Amount Hero Card ───────── */
.km-amount-hero {
    background: linear-gradient(135deg, #002046 0%, #0d3b66 100%) !important;
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(0, 32, 70, 0.18);
    position: relative;
    overflow: hidden;
    border: 1px solid #002046;
}
.km-amount-hero::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    pointer-events: none;
}
.km-amount-hero-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #87a0cd;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.km-amount-hero-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.14);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    border-radius: 0.5rem;
    padding: 0.35rem 0.75rem;
    transition: all 0.2s ease;
}
.km-amount-hero-input-wrap:focus-within {
    background: rgba(255, 255, 255, 0.25);
    border-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}
.km-amount-hero-input {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    color: #ffffff !important;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 24px;
    font-weight: 700;
    text-align: right;
    width: 100%;
    padding: 0 !important;
    margin: 0;
}
.km-amount-hero-input::placeholder {
    color: rgba(255, 255, 255, 0.45);
}
.km-amount-hero-words {
    margin-top: 0.5rem;
    font-size: 11px;
    color: #dce9ff;
    font-weight: 500;
    line-height: 1.4;
}

/* ───────── Accounting Grid & Table Inputs ───────── */
.km-grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.km-grid-table thead {
    background: #002046;
    color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 10;
}
.km-grid-table thead th {
    padding: 0.65rem 0.75rem;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 2px solid #00152e;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}
.km-grid-table thead th:last-child {
    border-right: none;
}
.km-grid-table tbody tr {
    border-bottom: 1px solid #E2E8F0;
    transition: background-color 0.15s ease;
    background: #ffffff;
}
.km-grid-table tbody tr:nth-child(even) {
    background: #FAFBFD;
}
.km-grid-table tbody tr:hover {
    background: #EFF6FF;
}
.km-grid-table tbody td {
    padding: 0.35rem 0.5rem;
    vertical-align: middle;
    border-right: 1px solid #E2E8F0;
}
.km-grid-table tbody td:last-child {
    border-right: none;
}
.km-grid-cell-input {
    display: block;
    width: 100%;
    height: 34px;
    padding: 0.35rem 0.6rem;
    font-size: 12px;
    line-height: 1.4;
    color: #0b1c30;
    background-color: #ffffff;
    border: 1px solid #CBD5E1;
    border-radius: 0.25rem;
    transition: all 0.15s ease;
    outline: none;
    box-sizing: border-box;
}
.km-grid-cell-input:hover {
    border-color: #94a3b8;
}
.km-grid-cell-input:focus {
    border-color: #002046;
    box-shadow: 0 0 0 2px rgba(0, 32, 70, 0.18);
    background-color: #ffffff;
}
.km-grid-cell-select {
    display: block;
    width: 100%;
    height: 34px;
    padding: 0.35rem 0.5rem;
    font-size: 12px;
    color: #0b1c30;
    background-color: #ffffff;
    border: 1px solid #CBD5E1;
    border-radius: 0.25rem;
    transition: all 0.15s ease;
    outline: none;
    box-sizing: border-box;
}
.km-grid-cell-select:hover {
    border-color: #94a3b8;
}
.km-grid-cell-select:focus {
    border-color: #002046;
    box-shadow: 0 0 0 2px rgba(0, 32, 70, 0.18);
}
.km-grid-footer-row {
    background: #F1F5F9;
    border-top: 2px solid #CBD5E1;
    font-weight: 700;
}
.km-grid-footer-row td {
    padding: 0.65rem 0.75rem;
    border-right: 1px solid #CBD5E1;
}
.km-grid-footer-row td:last-child {
    border-right: none;
}

/* ───────── GL Double Entry Visualizer ───────── */
.km-gl-preview {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 0.5rem;
    overflow: hidden;
}
.km-gl-preview-header {
    padding: 0.5rem 0.75rem;
    background: #EFF4FF;
    border-bottom: 1px solid #DBEAFE;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #1E3A8A;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.km-gl-preview-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #F1F5F9;
    font-size: 12px;
}
.km-gl-preview-row:last-child {
    border-bottom: none;
}
.km-badge-debit {
    background: #DEF7EC;
    color: #03543F;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.04em;
}
.km-badge-credit {
    background: #E1EFFE;
    color: #1E429F;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.04em;
}

/* section heading inside forms */
.km-section-title {
    font-size:12px; font-weight:600; letter-spacing:.05em; text-transform:uppercase; color:#002046;
    border-bottom:1px solid #E2E8F0; padding-bottom:.25rem; margin-bottom:1rem;
}

/* ───────── Slide-over panel ───────── */
.km-overlay { position:fixed; inset:0; background:rgba(0,0,0,.2); backdrop-filter:blur(2px); z-index:40; }
.km-panel {
    position:fixed; top:0; bottom:0; right:0; width:100%; background:#fff; z-index:50;
    display:flex; flex-direction:column; box-shadow:-8px 0 24px rgba(0,0,0,.12);
}
@media (min-width:768px) { .km-panel { width:800px; } .km-panel-sm { width:560px; } .km-panel-lg { width:900px; } }
.km-panel-header {
    padding:1rem 1.5rem; border-bottom:1px solid #E2E8F0; background:#F8FAFC;
    display:flex; justify-content:space-between; align-items:center; flex-shrink:0;
}
.km-panel-header h3 { margin:0; font-size:20px; line-height:28px; font-weight:600; color:#002046; }
.km-panel-body { flex:1; overflow-y:auto; padding:1.5rem; }
.km-panel-footer {
    padding:1rem; border-top:1px solid #E2E8F0; background:#F8FAFC;
    display:flex; justify-content:flex-end; gap:.75rem; flex-shrink:0;
}

/* ───────── Page header ───────── */
.km-page-title { font-size:32px; line-height:40px; letter-spacing:-.02em; font-weight:700; color:#002046; margin:0; }
.km-page-sub { font-size:14px; color:#44474e; margin:.25rem 0 0; }

/* ───────── Alerts ───────── */
.km-alert-error { background:#ffdad6; color:#93000a; border:1px solid rgba(186,26,26,.2);
    padding:.5rem .75rem; border-radius:.25rem; font-size:14px; }
.km-alert-ok { background:#ECFDF5; color:#065f46; border:1px solid rgba(16,185,129,.25);
    padding:.5rem .75rem; border-radius:.25rem; font-size:14px; }
.km-empty { padding:3rem 1rem; text-align:center; color:#44474e; font-size:14px; }
.km-empty .material-symbols-outlined { font-size:40px; color:#c4c6cf; display:block; margin:0 auto .5rem; }

/* ───────── Global Print Styles ───────── */
@media print {
    @page {
        size: A4 portrait;
        margin: 0; /* Setting margin to 0 prevents browser URL and date from printing */
    }
    aside, header, nav, .print\:hidden {
        display: none !important;
    }
    body {
        margin: 0 !important;
        padding: 10mm 8mm !important; /* Move margins to body padding */
        background: #fff !important;
    }
    main, div {
        margin: 0 !important;
        background: #fff !important;
    }
    /* Remove card styling, max-width, and padding overrides for print */
    .max-w-7xl { max-width: 100% !important; }
    .km-card {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }
    .pb-24 { padding-bottom: 0 !important; }

    /* Make table fit A4 width */
    .overflow-x-auto { overflow: visible !important; }
    
    .km-table {
        table-layout: fixed !important;
        width: 100% !important;
        font-size: 9px !important;
        border-collapse: collapse !important;
        border: 1px solid #000 !important;
    }
    .km-table > thead > tr > th,
    .km-table > tbody > tr > td,
    .km-table > tfoot > tr > td,
    .km-table th,
    .km-table td {
        padding: 3px 5px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        border: 1px solid #000 !important;
    }
    .km-table th {
        background-color: #fff !important;
        color: #000 !important;
    }
    /* Column widths: Date | Voucher | Type | Debit | Credit | Balance */
    .km-table th:nth-child(1), .km-table td:nth-child(1) { width: 14%; }
    .km-table th:nth-child(2), .km-table td:nth-child(2) { width: 10%; }
    .km-table th:nth-child(3), .km-table td:nth-child(3) { width: 30%; white-space: normal !important; }
    .km-table th:nth-child(4), .km-table td:nth-child(4) { width: 14%; }
    .km-table th:nth-child(5), .km-table td:nth-child(5) { width: 14%; }
    .km-table th:nth-child(6), .km-table td:nth-child(6) { width: 18%; }

    .km-table tfoot td { 
        font-size: 11px !important; 
        padding: 4px 5px !important; 
        border-top: 2px solid #000 !important;
    }

    /* Summary cards: compact print layout */
    .grid.sm\:grid-cols-3 { display: flex !important; gap: 8px !important; margin-bottom: 8px !important; }
    .grid.sm\:grid-cols-3 > div {
        flex: 1 !important;
        padding: 4px 8px !important;
        border: 0.5px solid #ccc !important;
        font-size: 10px !important;
    }
    .grid.sm\:grid-cols-3 .text-2xl { font-size: 14px !important; }

    /* Hide filter icons/buttons inside column headers */
    .km-table th button,
    .km-table th .material-symbols-outlined {
        display: none !important;
    }

    /* Ensure text is black for readability */
    .km-table, .km-table th, .km-table td, .km-table span {
        color: #000 !important;
    }
    .km-table tfoot tr { background: #f5f5f5 !important; }
}
