/* KhataBahi Dashboard Styles */
:root {
    --kb-primary: #1e3a8a;
    --kb-primary-hover: #1d4ed8;
    --kb-secondary: #475569;
    --kb-bg: #f8fafc;
    --kb-surface: #ffffff;
    --kb-text: #0f172a;
    --kb-border: #e2e8f0;
    --kb-success: #16a34a;
    --kb-warning: #d97706;
    --kb-danger: #dc2626;
    --kb-info: #0284c7;
    --kb-radius: 8px;
    --kb-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Parent WordPress Theme Container Overrides */
body:has(.kb-dashboard-container) .entry-content,
body:has(.kb-dashboard-container) .site-content,
body:has(.kb-dashboard-container) .post-inner,
body:has(.kb-dashboard-container) .wp-block-post-content,
body:has(.kb-dashboard-container) .site-main,
body:has(.kb-dashboard-container) .container,
body:has(.kb-dashboard-container) .ast-container,
body:has(.kb-dashboard-container) main,
body:has(.kb-dashboard-container) article {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Bulletproof Viewport Breakout for KhataBahi Dashboard */
.kb-dashboard-container {
    display: flex;
    min-height: 85vh;
    width: 100vw !important;
    max-width: 100vw !important;
    position: relative !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    background-color: var(--kb-bg);
    border-radius: 0px;
    overflow: hidden;
    box-shadow: none;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--kb-text);
    box-sizing: border-box !important;
}

/* Sidebar */
.kb-sidebar {
    width: 260px;
    background: #0f172a;
    color: #f8fafc;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
}

.kb-brand h2 {
    color: #ffffff;
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.kb-logo-icon {
    font-size: 26px;
}

.kb-nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.kb-nav-item {
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #94a3b8;
    transition: all 0.2s ease;
    font-weight: 500;
    margin-bottom: 4px;
}

.kb-nav-item:hover, .kb-nav-item.active {
    background: #1e293b;
    color: #38bdf8;
}

.kb-user-badge {
    padding-top: 16px;
    border-top: 1px solid #334155;
    font-size: 14px;
}

.kb-user-name {
    font-weight: 600;
    color: #ffffff;
}

.kb-logout-link {
    color: #f87171;
    text-decoration: none;
    font-size: 13px;
}

/* Main Content */
.kb-main-content {
    flex: 1;
    padding: 30px;
    background: #ffffff;
    overflow-y: auto;
}

.kb-tab-pane {
    display: none;
}

.kb-tab-pane.active {
    display: block;
}

.kb-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.kb-page-header h1, .kb-page-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
}

/* Stats Cards */
.kb-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kb-stat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--kb-shadow);
}

.kb-stat-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
}

.kb-stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--kb-primary);
    margin: 8px 0;
}

.kb-stat-success .kb-stat-value { color: var(--kb-success); }
.kb-stat-warning .kb-stat-value { color: var(--kb-warning); }

.kb-stat-sub {
    font-size: 12px;
    color: #94a3b8;
}

/* Tables */
.kb-table-responsive {
    overflow-x: auto;
}

.kb-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.kb-table th, .kb-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
}

.kb-table th {
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
}

.kb-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
}

.kb-badge-paid, .kb-badge-approved { background: #dcfce7; color: #15803d; }
.kb-badge-pending { background: #fef3c7; color: #b45309; }
.kb-badge-overdue, .kb-badge-rejected { background: #fee2e2; color: #b91c1c; }

/* Buttons */
.kb-btn {
    padding: 9px 18px;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
}

.kb-btn-primary { background: var(--kb-primary); color: #fff; }
.kb-btn-primary:hover { background: var(--kb-primary-hover); }
.kb-btn-secondary { background: #e2e8f0; color: #334155; }
.kb-btn-success { background: #25d366; color: #fff; }
.kb-btn-success:hover { background: #1da851; }
.kb-btn-info { background: #0284c7; color: #fff; }
.kb-btn-info:hover { background: #0369a1; }
.kb-btn-danger { background: #ef4444; color: #fff; }
.kb-btn-sm { padding: 5px 10px; font-size: 12px; }

/* Forms */
.kb-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.kb-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.kb-form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.kb-form-group input, .kb-form-group select, .kb-form-group textarea {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}

.kb-card-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 20px;
}

.kb-totals-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.kb-calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.kb-calc-row input {
    width: 120px;
    text-align: right;
    padding: 6px;
}

.kb-grand-total-row {
    font-weight: 700;
    font-size: 16px;
    border-top: 2px solid #cbd5e1;
    padding-top: 10px;
    color: var(--kb-primary);
}

.kb-words-preview {
    margin-top: 10px;
    padding: 10px;
    background: #e0f2fe;
    border-radius: 6px;
    font-size: 13px;
    color: #0369a1;
}

/* Modals */
.kb-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.7);
    justify-content: center;
    align-items: center;
}

.kb-modal.active { display: flex; }

.kb-modal-content {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.kb-modal-lg { max-width: 900px; }

.kb-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.kb-close-modal {
    font-size: 24px;
    cursor: pointer;
    color: #64748b;
}

.kb-approval-pending-card {
    text-align: center;
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    border: 2px solid #fde68a;
    max-width: 600px;
    margin: 40px auto;
}

.kb-approval-pending-card .kb-icon {
    font-size: 50px;
    margin-bottom: 10px;
}
