/* PPRPS - Project Payment Progress Management System */
:root {
    --primary: #1a3a5c;
    --primary-dark: #0f2540;
    --primary-light: #2563a8;
    --secondary: #e8a020;
    --secondary-dark: #c47d10;
    --success: #198754;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #0dcaf0;
    --sidebar-width: 260px;
    --header-height: 60px;
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: var(--font-sans);
    background: #f0f4f8;
    margin: 0;
    min-height: 100vh;
}

/* ===== AUTH PAGES ===== */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
}

.auth-header {
    background: var(--primary);
    padding: 2rem;
    text-align: center;
    color: #fff;
}

.auth-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    display: block;
}

.auth-header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    letter-spacing: 0.5px;
}

.auth-header p {
    font-size: 0.8rem;
    opacity: 0.75;
    margin: 0;
}

.auth-body { padding: 2rem; }

.auth-body .form-label { font-weight: 600; font-size: 0.85rem; color: #374151; }

.auth-body .form-control {
    border-radius: 8px;
    border: 1.5px solid #d1d5db;
    padding: 0.65rem 0.9rem;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.auth-body .form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37,99,168,0.15);
}

.btn-login {
    background: var(--primary);
    color: #fff;
    border: none;
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: background 0.2s, transform 0.1s;
    cursor: pointer;
}

.btn-login:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }

/* ===== SIDEBAR LAYOUT ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.sidebar-brand img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-brand-text h2 {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.sidebar-brand-text span {
    color: rgba(255,255,255,0.6);
    font-size: 0.7rem;
    display: block;
}

.sidebar-user {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-avatar {
    width: 38px;
    height: 38px;
    background: var(--secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; }
.sidebar-user-info .name {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-info .role {
    color: rgba(255,255,255,0.55);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    list-style: none;
    margin: 0;
}

.sidebar-nav .nav-section {
    color: rgba(255,255,255,0.4);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.75rem 1.25rem 0.25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: #fff;
    background: rgba(255,255,255,0.08);
    border-left-color: var(--secondary);
}

.sidebar-nav a i { width: 18px; text-align: center; font-size: 1rem; }

.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 0.5rem 0;
    transition: color 0.2s;
}

.sidebar-footer a:hover { color: #fff; }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

.topbar {
    background: #fff;
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 500;
    gap: 1rem;
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--primary);
    cursor: pointer;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    flex: 1;
}

.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ===== CARDS ===== */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    border: none;
}

.card-header {
    background: none;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== STAT CARDS ===== */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green  { background: #dcfce7; color: #15803d; }
.stat-icon.yellow { background: #fef9c3; color: #b45309; }
.stat-icon.red    { background: #fee2e2; color: #b91c1c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.orange { background: #ffedd5; color: #c2410c; }

.stat-info .value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #111827;
    line-height: 1;
}

.stat-info .label {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* ===== TABLES ===== */
.table-responsive {
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table { margin: 0; }

.table thead th {
    background: #f8fafc;
    color: #374151;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
    border-color: #f0f0f0;
    word-break: break-word;
    overflow-wrap: break-word;
}

.table tbody tr:hover { background: #f8fafc; }

/* ===== MOBILE CARD TABLE =====
   Add class="mobile-card-table" to any <table> to get
   a stacked card layout on small screens. Each <td>
   must have a data-label attribute.
*/
@media (max-width: 575px) {
    .mobile-card-table thead { display: none; }

    .mobile-card-table tbody tr {
        display: block;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        margin-bottom: 0.75rem;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06);
        overflow: hidden;
    }

    .mobile-card-table tbody tr:hover { background: #fff; }

    .mobile-card-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.55rem 0.85rem;
        border: none;
        border-bottom: 1px solid #f3f4f6;
        font-size: 0.85rem;
    }

    .mobile-card-table tbody td:last-child { border-bottom: none; }

    .mobile-card-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        flex-shrink: 0;
        padding-top: 0.1rem;
        min-width: 90px;
    }

    .mobile-card-table tbody td .actions-cell {
        flex-wrap: wrap;
        gap: 0.35rem;
    }
}

/* ===== BADGES ===== */
.badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    letter-spacing: 0.25px;
}

/* ===== BUTTONS ===== */
.btn { border-radius: 8px; font-size: 0.875rem; font-weight: 500; }
.btn-sm { font-size: 0.8rem; padding: 0.35rem 0.7rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ===== FORMS ===== */
.form-label { font-weight: 600; font-size: 0.85rem; color: #374151; }
.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid #d1d5db;
    font-size: 0.875rem;
    padding: 0.55rem 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37,99,168,0.12);
    outline: none;
}

/* ===== TIMELINE (Approval Logs) ===== */
.timeline { position: relative; padding-left: 2.5rem; }
.timeline::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e5e7eb;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-icon {
    position: absolute;
    left: -2.5rem;
    top: 0.15rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #e5e7eb;
}

.timeline-icon.submitted { background: #3b82f6; color: #fff; }
.timeline-icon.accepted  { background: #10b981; color: #fff; }
.timeline-icon.rejected  { background: #ef4444; color: #fff; }
.timeline-icon.cheque_ready { background: #8b5cf6; color: #fff; }
.timeline-icon.issued    { background: #059669; color: #fff; }

.timeline-content {
    background: #f9fafb;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    border: 1px solid #e5e7eb;
}

.timeline-content .meta {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 0.35rem;
}

.timeline-content .comment {
    font-size: 0.875rem;
    color: #374151;
}

/* ===== STATUS PILL ===== */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
}

.status-pill::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* ===== ALERTS ===== */
.alert { border-radius: 10px; border: none; font-size: 0.875rem; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

    .sidebar-overlay.open { display: block; }

    .main-content {
        margin-left: 0;
    }

    .topbar-toggle { display: block; }

    .page-content { padding: 0.85rem; }

    .stat-card { padding: 0.85rem; gap: 0.65rem; }
    .stat-icon { width: 42px; height: 42px; font-size: 1.1rem; }
    .stat-info .value { font-size: 1.25rem; }
    .stat-info .label { font-size: 0.72rem; }

    .page-header h1 { font-size: 1.1rem; }

    .card-header { font-size: 0.875rem; padding: 0.75rem 1rem; }
}

@media (max-width: 575px) {
    .page-content { padding: 0.75rem; }

    /* Tighter row gaps on very small screens */
    .row.g-3 { --bs-gutter-x: 0.75rem; --bs-gutter-y: 0.75rem; }

    /* Make breadcrumb compact */
    .breadcrumb { font-size: 0.72rem; }

    /* Timeline on small screens */
    .timeline { padding-left: 2rem; }
    .timeline-icon { left: -2rem; width: 26px; height: 26px; font-size: 0.75rem; }

    /* Full-width buttons in card footers */
    .card-footer .btn { font-size: 0.8rem; padding: 0.4rem 0.6rem; }

    /* Page header stacks */
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header .btn { align-self: flex-start; }

    /* Stat cards: smaller values */
    .stat-info .value { font-size: 1.15rem; }
    .amount.large { font-size: 1.2rem; }
}

/* ===== OFFLINE BANNER ===== */
.offline-banner {
    background: #ef4444;
    color: #fff;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.85rem;
    display: none;
}

/* ===== PWA INSTALL ===== */
.pwa-install-btn {
    display: none;
    background: var(--secondary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.pwa-install-btn:hover { background: var(--secondary-dark); }
.pwa-install-btn.visible { display: flex; align-items: center; gap: 0.4rem; }

/* ===== AMOUNT DISPLAY ===== */
.amount {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    word-break: break-all;
    overflow-wrap: break-word;
}
.amount.large { font-size: 1.4rem; }

/* ===== BREADCRUMB ===== */
.breadcrumb { font-size: 0.8rem; margin-bottom: 0; }
.breadcrumb-item a { color: var(--primary-light); text-decoration: none; }
.breadcrumb-item.active { color: #6b7280; }
