/* ==========================================================================
   RentWise — Corporate Admin Theme
   All colors are CSS variables. Per-building branding (caretaker/settings.php)
   overrides --primary-color, --sidebar-bg and --accent-emerald at :root from
   includes/header.php, and every derived shade below follows automatically.
   ========================================================================== */
:root {
    --primary-color: #1e3a8a;   /* Navy */
    --primary-dark: #16307a;
    --sidebar-bg: #1e3a8a;
    --accent-emerald: #10b981;
    --slate-grey: #64748b;
    --modern-orange: #f97316;
    --bg-light: #f6f8fb;
    --surface: #ffffff;
    --border-color: #e6eaf1;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --sidebar-width: 264px;
    --sidebar-text: rgba(255, 255, 255, 0.72);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 6px 16px rgba(15, 23, 42, 0.05);
}

/* ---------- Base ---------- */
body {
    background-color: var(--bg-light);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    font-size: 0.925rem;
}

h4, h5, h6 { letter-spacing: -0.01em; }

a { text-decoration: none; }

/* ---------- Color helpers (theme driven) ---------- */
.bg-navy { background-color: var(--primary-color) !important; }
.text-navy { color: var(--primary-color) !important; }
.bg-emerald { background-color: var(--accent-emerald) !important; }
.text-emerald { color: var(--accent-emerald) !important; }
.bg-orange { background-color: var(--modern-orange) !important; }
.text-orange { color: var(--modern-orange) !important; }
.bg-slate { background-color: var(--slate-grey) !important; }
.text-slate { color: var(--slate-grey) !important; }
.text-slate-grey { color: var(--slate-grey) !important; }

.bg-emerald-subtle { background-color: color-mix(in srgb, var(--accent-emerald) 12%, white) !important; }
.bg-orange-subtle { background-color: color-mix(in srgb, var(--modern-orange) 12%, white) !important; }
.bg-navy-subtle { background-color: color-mix(in srgb, var(--primary-color) 10%, white) !important; }
.bg-slate-subtle { background-color: color-mix(in srgb, var(--slate-grey) 12%, white) !important; }

/* ---------- Utilities pages rely on ---------- */
.fs-xs { font-size: 0.7rem; }
.min-w-0 { min-width: 0; }
.italic { font-style: italic; }
.tracking-wider { letter-spacing: 0.1em; }
.hide-caret::after { display: none; }
.last-child-border-0:last-child {
    border-bottom: 0 !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* ---------- Buttons ---------- */
.btn { font-weight: 500; border-radius: var(--radius-sm); }
.btn:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-emerald) 35%, transparent);
}

.btn-emerald {
    background-color: var(--accent-emerald);
    border: none;
    color: #fff;
}
.btn-emerald:hover {
    background-color: color-mix(in srgb, var(--accent-emerald) 88%, black);
    color: #fff;
}

.btn-outline-emerald {
    color: var(--accent-emerald);
    border: 1px solid var(--accent-emerald);
    background: transparent;
}
.btn-outline-emerald:hover { background-color: var(--accent-emerald); color: #fff; }

/* Quiet icon-only action buttons (table rows, toolbars) */
.btn-ghost {
    background: transparent;
    border: none;
    color: var(--slate-grey);
}
.btn-ghost:hover { background-color: #eef1f6; color: var(--primary-color); }

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}
.card-title { font-size: 1rem; }

/* ---------- Stat card (KPIs) ---------- */
.stat-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem 1.1rem;
    height: 100%;
}
.stat-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}
.stat-navy   { background: color-mix(in srgb, var(--primary-color) 10%, white); color: var(--primary-color); }
.stat-emerald{ background: color-mix(in srgb, var(--accent-emerald) 12%, white); color: color-mix(in srgb, var(--accent-emerald) 80%, black); }
.stat-orange { background: color-mix(in srgb, var(--modern-orange) 12%, white); color: color-mix(in srgb, var(--modern-orange) 85%, black); }
.stat-danger { background: color-mix(in srgb, #ef4444 10%, white); color: #dc2626; }
.stat-slate  { background: color-mix(in srgb, var(--slate-grey) 12%, white); color: var(--slate-grey); }

.stat-card small {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-card .stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Page header ---------- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

/* ---------- Sidebar ---------- */
#sidebar-wrapper {
    position: sticky;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-emerald);
    font-size: 1rem;
    flex-shrink: 0;
}
.brand-name { color: #fff; font-weight: 700; font-size: 1.05rem; line-height: 1.15; }
.sidebar-brand small {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding-bottom: 0.5rem; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }

.sidebar-label {
    padding: 1rem 1.5rem 0.35rem;
    font-size: 0.65rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.38);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.9rem;
    margin: 1px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--sidebar-text);
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-link i { width: 18px; text-align: center; font-size: 0.9rem; }
.sidebar-link:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.sidebar-link.active { color: #fff; background: rgba(255, 255, 255, 0.14); }

.sidebar-footer {
    padding: 0.9rem 1.5rem;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

/* Mobile: off-canvas sidebar with backdrop */
.sidebar-backdrop { display: none; }

@media (max-width: 767.98px) {
    #sidebar-wrapper {
        position: fixed;
        top: 0;
        left: 0;
        transform: translateX(-100%);
        z-index: 1060;
        box-shadow: none;
    }
    #wrapper.toggled #sidebar-wrapper {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(15, 23, 42, 0.35);
    }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 1055;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }
    #wrapper.toggled .sidebar-backdrop { opacity: 1; visibility: visible; }
}

/* ---------- Top navbar ---------- */
.app-navbar {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}
.app-navbar .page-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 1rem;
    margin: 0;
}
.nav-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--slate-grey);
    background: transparent;
    border: none;
}
.nav-icon-btn:hover { background: #eef1f6; color: var(--primary-color); }

.avatar-sm {
    width: 34px;
    height: 34px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ---------- Page content ---------- */
#page-content-wrapper { min-width: 100vw; flex: 1; }

@media (min-width: 768px) {
    #page-content-wrapper { min-width: 0; width: 100%; }
}

/* ---------- Tables ---------- */
.table { --bs-table-hover-bg: #f7f9fc; margin-bottom: 0; }
.table thead th {
    background: #f8fafc;
    color: var(--slate-grey);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.table tbody td {
    padding: 0.8rem 1rem;
    border-color: #eef1f6;
    font-size: 0.85rem;
    vertical-align: middle;
    color: var(--text-main);
}
.table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Badges ---------- */
.badge {
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.4em 0.75em;
    border-radius: 6px;
    letter-spacing: 0.02em;
}
.badge.rounded-pill { border-radius: 50rem; }

/* ---------- Modals ---------- */
.modal-content { border: none; border-radius: var(--radius); }
.modal-header { border-bottom: 1px solid var(--border-color); }
.modal-title { font-size: 1rem; font-weight: 600; color: var(--text-main); }
.modal-footer {
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    font-size: 0.875rem;
}
.form-control:focus, .form-select:focus {
    border-color: color-mix(in srgb, var(--accent-emerald) 50%, white);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-emerald) 15%, transparent);
}
.form-label { font-size: 0.78rem; margin-bottom: 0.35rem; }

/* ---------- DataTables ---------- */
.dataTables_wrapper { padding: 1rem; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.55rem;
    font-size: 0.8rem;
    outline: none;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--accent-emerald); }
.dataTables_wrapper .dataTables_info { font-size: 0.75rem; color: var(--text-muted); }
.dataTables_wrapper .dataTables_paginate .page-link {
    border: none;
    color: var(--slate-grey);
    font-size: 0.8rem;
    min-width: 30px;
    text-align: center;
    border-radius: 8px !important;
    margin: 0 2px;
    padding: 0.35rem 0.55rem;
}
.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
    background: var(--primary-color);
    color: #fff;
}

/* ---------- Empty state ---------- */
.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--text-muted); }
.empty-state i { font-size: 1.75rem; color: #cbd5e1; display: block; margin-bottom: 0.5rem; }

/* ---------- Toasts ---------- */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(92vw, 360px);
}
.toast.app-toast {
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-emerald);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.toast.app-toast.t-danger { border-left-color: #dc2626; }
.toast.app-toast.t-info { border-left-color: var(--primary-color); }
.toast.app-toast.t-warning { border-left-color: var(--modern-orange); }

/* ---------- Dropdowns ---------- */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 0.85rem;
}
.dropdown-item:active { background: var(--primary-color); }

/* ---------- Login ---------- */
.login-shell {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 60%, #0b1220));
    padding: 1rem;
}
.login-card { max-width: 400px; width: 100%; border-radius: 16px; overflow: hidden; }
.login-brand {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: var(--accent-emerald);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

/* ---------- Mobile responsiveness ---------- */
@media (max-width: 767.98px) {
    .container-fluid.p-4 { padding: 1rem !important; }
    .card-body.p-4, .modal-body.p-4, .modal-header.p-4, .card-header.p-4 { padding: 1rem !important; }
    .modal-footer.p-3 { padding: 0.75rem 1rem !important; }
    h4 { font-size: 1.15rem; }
    h3 { font-size: 1.1rem; }

    .stat-card { padding: 0.85rem 0.9rem; gap: 0.65rem; }
    .stat-card .stat-value { font-size: 1rem; }
    .stat-icon { width: 36px; height: 36px; font-size: 0.85rem; }

    .table thead th, .table tbody td { padding: 0.65rem 0.75rem; }

    #toast-container { top: auto; bottom: 1rem; right: 0.75rem; left: 0.75rem; width: auto; }
}

/* ---------- Selectable option cards (invoice mode toggle, etc.) ---------- */
.mode-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.mode-option {
    flex: 1 1 240px;
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    margin: 0;
    padding: 0.8rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.mode-option:hover { border-color: color-mix(in srgb, var(--accent-emerald) 40%, white); }
.btn-check:focus-visible + .mode-option {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-emerald) 30%, transparent);
}
.mode-option .mode-icon {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    color: var(--slate-grey);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.mode-option .mode-title {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}
.mode-option .mode-desc {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--text-muted);
}
.mode-option .mode-check {
    flex: 0 0 auto;
    opacity: 0;
    color: var(--accent-emerald);
    transition: opacity 0.15s ease;
}
.btn-check:checked + .mode-option {
    border-color: var(--accent-emerald);
    background: color-mix(in srgb, var(--accent-emerald) 7%, white);
    box-shadow: 0 0 0 1px var(--accent-emerald);
}
.btn-check:checked + .mode-option .mode-icon {
    background: color-mix(in srgb, var(--accent-emerald) 15%, white);
    color: var(--accent-emerald);
}
.btn-check:checked + .mode-option .mode-check { opacity: 1; }

/* ---------- Invoice generator period picker ---------- */
.gen-period-row { cursor: pointer; border-radius: var(--radius-sm); }
.gen-period-row:hover { background: rgba(15, 23, 42, 0.025); }
.gen-period-row:last-child { border-bottom: 0 !important; }

/* Receipt/invoice document preview panel */
.doc-panel {
    background: var(--bg-light);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem 1.1rem;
}
.fs-sm { font-size: 0.8rem; }

/* ---------- Manual rent reminder modal ---------- */
/* Full-width option cards: the sentence that will actually be sent stays readable */
.remind-options .mode-option { flex: 1 1 100%; }
.remind-preview {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-main);
    max-height: 140px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

