/* assets/css/style.css */

:root {
    --olive: #6B8E23;
    --olive-light: #8AAB3A;
    --olive-dark: #556B1E;
    --olive-bg: #f0f4e8;
    --olive-bg-light: #f7f9f2;
    --sidebar-width: 200px;
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f0f1f3;
    --gray-200: #e2e4e7;
    --gray-500: #8c919a;
    --gray-700: #4a4f57;
    --gray-900: #1a1d23;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --transition: all 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ---- AUTH PAGES ---- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--olive-bg) 0%, var(--white) 100%);
}

.auth-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.auth-card .auth-logo {
    height: 64px;
    margin-bottom: 16px;
}

.auth-card h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--gray-900);
}

.auth-card .subtitle {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 32px;
}

.auth-card .form-label {
    text-align: left;
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.auth-card .form-control, .auth-card .form-select {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    transition: var(--transition);
}

.auth-card .form-control:focus, .auth-card .form-select:focus {
    border-color: var(--olive);
    box-shadow: 0 0 0 3px rgba(107,142,35,0.15);
}

/* Code Input */
.code-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 24px 0;
}

.code-inputs input {
    width: 50px;
    height: 56px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    transition: var(--transition);
    color: var(--olive-dark);
}

.code-inputs input:focus {
    border-color: var(--olive);
    box-shadow: 0 0 0 3px rgba(107,142,35,0.15);
    outline: none;
}

/* Buttons */
.btn-olive {
    background: var(--olive);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.btn-olive:hover {
    background: var(--olive-light);
    color: var(--white);
}

.btn-olive:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-olive-outline {
    background: transparent;
    color: var(--olive);
    border: 1px solid var(--olive);
    border-radius: var(--radius);
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-olive-outline:hover {
    background: var(--olive);
    color: var(--white);
}

.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ---- LAYOUT ---- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--gray-100);
}

.sidebar-logo img {
    max-width: 120px;
    max-height: 50px;
    object-fit: contain;
}

.sidebar-company {
    padding: 12px 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--olive);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-100);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--olive-bg-light);
    color: var(--olive-dark);
}

.sidebar-link.active {
    background: var(--olive-bg);
    color: var(--olive);
    border-left-color: var(--olive);
}

.sidebar-link i { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer {
    border-top: 1px solid var(--gray-100);
    padding: 12px 0;
}

.sidebar-user {
    padding: 8px 20px;
    font-size: 12px;
    color: var(--gray-500);
}

.logout-link { color: #dc3545 !important; }
.logout-link:hover { background: #fef2f2 !important; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    color: var(--gray-900);
}

/* Cards & Tables */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header-olive {
    background: var(--olive-bg-light);
    border-bottom: 1px solid var(--gray-200);
    padding: 14px 20px;
    font-weight: 600;
    font-size: 14px;
    color: var(--olive-dark);
}

.table {
    margin: 0;
    font-size: 13px;
}

.table thead th {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--gray-500);
    padding: 12px 16px;
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-100);
}

.table tbody tr:hover { background: var(--olive-bg-light); }

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

/* Flash Messages */
.alert-rms {
    border-radius: var(--radius);
    padding: 12px 20px;
    font-size: 13px;
    margin-bottom: 20px;
    border: none;
}

/* Form Panel */
.form-panel {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    max-width: 640px;
}

.form-panel .form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-panel .form-control,
.form-panel .form-select {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    padding: 8px 12px;
}

.form-panel .form-control:focus,
.form-panel .form-select:focus {
    border-color: var(--olive);
    box-shadow: 0 0 0 3px rgba(107,142,35,0.12);
}

/* Thumbnail Preview */
.thumb-preview {
    width: 140px;
    height: 180px;
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    background: var(--gray-50);
    overflow: hidden;
}

.thumb-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.thumb-preview .placeholder-text {
    color: var(--gray-500);
    font-size: 11px;
    text-align: center;
}

/* Modal */
.modal-header { border-bottom: 1px solid var(--gray-200); }
.modal-footer { border-top: 1px solid var(--gray-200); }

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar .form-control,
.filter-bar .form-select {
    font-size: 13px;
    padding: 6px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    max-width: 200px;
}

/* Action Buttons in Table */
.action-btns { display: flex; gap: 6px; }
.action-btns .btn {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 6px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-link span,
    .sidebar-company,
    .sidebar-user { display: none; }
    .sidebar-logo img { max-width: 36px; }
    .main-content { margin-left: 60px; padding: 16px; }
}

/* Utility */
.text-olive { color: var(--olive) !important; }
.bg-olive { background-color: var(--olive) !important; }
.border-olive { border-color: var(--olive) !important; }
.mt-1 { margin-top: 4px; }
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; color: var(--gray-200); }
.empty-state p { font-size: 14px; }
/* =========================================================================
   Additions: roles, dashboard stats, invoicing, system status
   ========================================================================= */

/* ---- Auth extras ---- */
.auth-help {
    margin-top: 18px;
    font-size: 12px;
    color: var(--gray-500);
    line-height: 1.5;
}
.portal-tag {
    display: inline-block;
    margin: -6px 0 14px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--olive-bg);
    color: var(--olive-dark);
    font-size: 12px;
    font-weight: 600;
}

/* ---- Role chips ---- */
.role-chip {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    vertical-align: middle;
}
.role-chip:only-child { background: var(--gray-100); color: var(--gray-700); }

/* ---- Sidebar section divider ---- */
.sidebar-section {
    margin: 16px 0 6px;
    padding: 0 16px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

/* ---- Dashboard stat tiles ---- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}
a.stat-tile:hover {
    border-color: var(--olive);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.stat-value { font-size: 22px; font-weight: 700; color: var(--olive-dark); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--gray-500); }
.stat-tile-money { background: var(--olive-bg-light); }
.stat-tile-money .stat-value { font-size: 19px; }

/* ---- Table states ---- */
.row-inactive { opacity: 0.55; }
.row-inactive:hover { opacity: 1; }

/* ---- Invoices ---- */
.invoice-balance th { border-top: 2px solid var(--gray-200); font-size: 16px; color: var(--olive-dark); }
.invoice-amount {
    margin: 0 0 16px;
    font-size: 30px;
    font-weight: 700;
    color: var(--olive-dark);
    line-height: 1.1;
}

/* ---- Documents ---- */
.doc-thumb {
    max-width: 120px;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
}
.request-notes {
    margin-top: 4px;
    padding: 12px 14px;
    background: var(--gray-50);
    border-left: 3px solid var(--olive);
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.6;
}
.card-footer-note {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    font-size: 12px;
    color: var(--gray-500);
}

/* ---- Settings system status ---- */
.status-check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
}
.status-check:last-of-type { border-bottom: 0; }
.status-check i { margin-top: 3px; }
.status-check small { font-size: 11px; line-height: 1.4; }

/* ---- Filter bar wrapping on small screens ---- */
.filter-bar { flex-wrap: wrap; }
@media (max-width: 768px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .filter-bar > * { flex: 1 1 100%; }
}

/* ---- Danger zone (admin-only destructive actions) ---- */
.card-danger-zone { border-color: #f1c6c9; }
.card-header-danger {
    padding: 12px 20px;
    background: #fdf2f3;
    border-bottom: 1px solid #f1c6c9;
    border-radius: var(--radius) var(--radius) 0 0;
    color: #b02a37;
    font-weight: 600;
    font-size: 14px;
}

/* ---- PDF viewer modal ----
   90% of the viewport, over a darker-than-default black overlay so the page
   behind recedes and the document is the only thing to look at. */
.pdf-modal-dialog {
    width: 90vw;
    max-width: 90vw;
    height: 90vh;
    margin: 5vh auto;
}
.pdf-modal-dialog .modal-content {
    height: 90vh;
    border: 0;
    border-radius: var(--radius);
    overflow: hidden;
}
.pdf-modal-dialog .modal-header {
    padding: 12px 18px;
    background: var(--olive-bg-light);
    border-bottom: 1px solid var(--gray-200);
}
.pdf-modal-dialog .modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--olive-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 55%;
}
.pdf-modal-dialog .modal-body { background: var(--gray-100); }
#pdfModalFrame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}
/* Bootstrap's default backdrop is 50% - this is deliberately heavier so the
   page behind genuinely recedes.
   Set through Bootstrap's own custom property rather than overriding opacity
   directly: its rule is `opacity: var(--bs-backdrop-opacity)`, and an opacity
   override has to win a cascade fight against the CDN stylesheet, which it
   does not reliably do. Feeding the variable always works. */
.modal-backdrop {
    --bs-backdrop-opacity: 0.75;
    --bs-backdrop-bg: #000;
    background-color: #000;
}
.modal-backdrop.show { opacity: var(--bs-backdrop-opacity); }

@media (max-width: 768px) {
    .pdf-modal-dialog {
        width: 96vw;
        max-width: 96vw;
        height: 94vh;
        margin: 3vh auto;
    }
    .pdf-modal-dialog .modal-content { height: 94vh; }
    .pdf-modal-dialog .modal-title { max-width: 40%; }
}
