/* ============================================
   LWC Branch Assessment System - Main Styles
   ============================================ */

/* ============================================
   CSS Variables / Theme Colors
   ============================================ */
:root {
    --lwc-primary: #0056a9;
    --lwc-primary-dark: #003d7a;
    --lwc-primary-light: #e8f0fe;
    --lwc-secondary: #f5a623;
    --lwc-secondary-dark: #e09515;
    --lwc-success: #28a745;
    --lwc-danger: #dc3545;
    --lwc-warning: #ffc107;
    --lwc-info: #17a2b8;
    --lwc-light: #f8f9fa;
    --lwc-dark: #343a40;
    --lwc-gray: #6c757d;
    --lwc-gray-light: #e9ecef;
    --lwc-border-radius: 15px;
    --lwc-box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    --lwc-box-shadow-hover: 0 6px 12px rgba(0, 0, 0, 0.1);
    --lwc-transition: all 0.3s ease;
}

/* ============================================
   Base Styles
   ============================================ */

html {
    min-height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f4f8;
    color: #333;
    min-height: 100vh;
    margin: 0;
}

/*
 * Public pages use the normal document flow.
 * Admin pages use .admin-page flex layout.
 */
body.admin-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
}

/* ============================================
   PUBLIC HEADER / NAVIGATION
   ============================================ */

.lwc-header {
    background: linear-gradient(
        135deg,
        var(--lwc-primary) 0%,
        var(--lwc-primary-dark) 100%
    );
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.lwc-header img {
    max-height: 60px;
    object-fit: contain;
}

.lwc-header h4 {
    font-weight: 600;
    letter-spacing: 0.5px;
}

.lwc-header small {
    opacity: 0.85;
}

/* ============================================
   ADMIN HEADER
   ============================================ */

.admin-header {
    flex: 0 0 auto;
    width: 100%;
    background: linear-gradient(
        135deg,
        var(--lwc-primary) 0%,
        var(--lwc-primary-dark) 100%
    );
    color: #ffffff;
    padding: 10px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
}

.admin-header strong {
    font-weight: 600;
}

.admin-header .btn {
    margin-left: 4px;
}

/* ============================================
   NAVBAR
   ============================================ */

.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.admin-nav {
    flex: 0 0 auto;
    width: 100%;
    position: relative;
    z-index: 9;
}

.navbar .nav-link {
    font-weight: 500;
    color: #555;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: var(--lwc-transition);
}

.navbar .nav-link:hover {
    color: var(--lwc-primary);
    background-color: var(--lwc-primary-light);
}

.navbar .nav-link.active {
    color: var(--lwc-primary);
    background-color: var(--lwc-primary-light);
    font-weight: 600;
}

.navbar .nav-link i {
    margin-right: 6px;
}

/* ============================================
   ADMIN MAIN CONTENT
   ============================================ */

.admin-main {
    flex: 1 0 auto;
    width: 100%;
    position: relative;
    display: block;
}

.admin-main > .container {
    width: 100%;
}

/* ============================================
   ADMIN FOOTER
   ============================================ */

.admin-footer {
    flex: 0 0 auto;
    width: 100%;
    background-color: #343a40;
    background-image: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 10px 0;
    margin-top: 30px;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.admin-footer small {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
}

.admin-footer .container {
    max-width: 100%;
}

/* ============================================
   PUBLIC FOOTER
   ============================================ */

body:not(.admin-page) footer {
    background-color: #343a40;
    background-image: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 10px 0;
    margin-top: 30px;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

body:not(.admin-page) footer small {
    color: rgba(255, 255, 255, 0.7);
}

/* ============================================
   Cards
   ============================================ */

.lwc-card {
    border: none;
    border-radius: var(--lwc-border-radius);
    box-shadow: var(--lwc-box-shadow);
    transition: var(--lwc-transition);
    background: white;
    overflow: hidden;
}

.lwc-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--lwc-box-shadow-hover);
}

.lwc-card .card-header {
    background: white;
    border-bottom: 1px solid var(--lwc-gray-light);
    padding: 1rem 1.25rem;
}

.lwc-card .card-header h5,
.lwc-card .card-header h6 {
    font-weight: 600;
}

.lwc-card .card-body {
    padding: 1.5rem;
}

/* ============================================
   Buttons
   ============================================ */

.btn-lwc-primary {
    background-color: var(--lwc-primary);
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 25px;
    transition: var(--lwc-transition);
    font-weight: 500;
    letter-spacing: 0.3px;
}

.btn-lwc-primary:hover {
    background-color: var(--lwc-primary-dark);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 86, 169, 0.3);
}

.btn-lwc-primary:active {
    transform: translateY(0);
}

.btn-lwc-secondary {
    background-color: var(--lwc-secondary);
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 25px;
    transition: var(--lwc-transition);
    font-weight: 500;
    letter-spacing: 0.3px;
}

.btn-lwc-secondary:hover {
    background-color: var(--lwc-secondary-dark);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(245, 166, 35, 0.3);
}

.btn-lwc-secondary:active {
    transform: translateY(0);
}

.btn-outline-lwc-primary {
    color: var(--lwc-primary);
    border: 2px solid var(--lwc-primary);
    background: transparent;
    padding: 8px 25px;
    border-radius: 25px;
    transition: var(--lwc-transition);
    font-weight: 500;
}

.btn-outline-lwc-primary:hover {
    background: var(--lwc-primary);
    color: white;
    transform: translateY(-2px);
}

/* ============================================
   Section Headers
   ============================================ */

.section-header {
    background: linear-gradient(
        135deg,
        var(--lwc-primary) 0%,
        var(--lwc-primary-dark) 100%
    );
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.section-header h5 {
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ============================================
   Form Elements
   ============================================ */

.required::after {
    content: " *";
    color: var(--lwc-danger);
    font-weight: bold;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--lwc-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 86, 169, 0.15);
}

.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #ced4da;
    transition: var(--lwc-transition);
}

.form-control-sm {
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
}

.form-check-input:checked {
    background-color: var(--lwc-primary);
    border-color: var(--lwc-primary);
}

/* ============================================
   Status Badges
   ============================================ */

.status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.status-completed {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-reviewed {
    background-color: #cce5ff;
    color: #004085;
    border: 1px solid #b8daff;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status-incomplete {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ============================================
   Admin Sidebar
   ============================================ */

.admin-sidebar {
    background: white;
    border-radius: var(--lwc-border-radius);
    padding: 20px;
    box-shadow: var(--lwc-box-shadow);
}

.admin-sidebar h6 {
    font-weight: 600;
    color: var(--lwc-dark);
    letter-spacing: 0.5px;
}

.admin-sidebar .nav-link {
    color: #555;
    padding: 10px 15px;
    border-radius: 8px;
    transition: var(--lwc-transition);
    font-weight: 500;
}

.admin-sidebar .nav-link:hover {
    background-color: var(--lwc-primary-light);
    color: var(--lwc-primary);
}

.admin-sidebar .nav-link.active {
    background-color: var(--lwc-primary);
    color: white;
}

.admin-sidebar .nav-link i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.admin-sidebar .nav-link .badge {
    margin-top: 2px;
}

/* ============================================
   Statistics Cards
   ============================================ */

.stat-card {
    background: white;
    padding: 20px;
    border-radius: var(--lwc-border-radius);
    text-align: center;
    box-shadow: var(--lwc-box-shadow);
    transition: var(--lwc-transition);
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--lwc-box-shadow-hover);
}

.stat-card .number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--lwc-primary);
    line-height: 1.2;
}

.stat-card .label {
    color: var(--lwc-gray);
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 5px;
}

.stat-card .icon {
    font-size: 2rem;
    color: var(--lwc-secondary);
    margin-bottom: 10px;
}

/* ============================================
   IGA Items
   ============================================ */

.iga-item {
    background: var(--lwc-light);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    border-left: 4px solid var(--lwc-primary);
    transition: var(--lwc-transition);
}

.iga-item:hover {
    background: #f0f4f8;
}

.iga-item .remove-iga {
    cursor: pointer;
    color: var(--lwc-danger);
    font-size: 1.2rem;
    transition: var(--lwc-transition);
}

.iga-item .remove-iga:hover {
    color: #bd2130;
    transform: scale(1.1);
}

/* ============================================
   Token Display
   ============================================ */

.token-display {
    background: var(--lwc-light);
    padding: 15px;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    letter-spacing: 2px;
    border: 2px dashed var(--lwc-primary);
    word-break: break-all;
}

/* ============================================
   Review Section
   ============================================ */

.review-section {
    background: #f0f7ff;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid #cce5ff;
}

.review-section h6 {
    color: var(--lwc-primary);
    font-weight: 600;
}

/* ============================================
   Review Section Cards
   ============================================ */

.review-section-card {
    border-left: 4px solid #0056a9;
    margin-bottom: 20px;
}

.review-section-card .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.review-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

.review-value {
    color: #212529;
    font-size: 0.95rem;
}

.review-value.na {
    color: #6c757d;
    font-style: italic;
}

.section-status-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
}

.review-table {
    font-size: 0.9rem;
}

.review-table td {
    padding: 6px 10px;
}

.review-table .label-col {
    width: 40%;
    font-weight: 500;
    color: #495057;
}

.review-table .value-col {
    width: 60%;
}

/* ============================================
   Progress Bar
   ============================================ */

.progress {
    border-radius: 10px;
    overflow: hidden;
    background-color: var(--lwc-gray-light);
}

.progress-bar {
    transition: width 0.6s ease;
    font-weight: 600;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Alerts
   ============================================ */

.alert {
    border-radius: 10px;
    border: none;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* ============================================
   Tables
   ============================================ */

.table {
    border-radius: 10px;
    overflow: hidden;
}

.table thead th {
    background-color: var(--lwc-light);
    border-bottom: 2px solid var(--lwc-gray-light);
    font-weight: 600;
    color: var(--lwc-dark);
}

.table-hover tbody tr:hover {
    background-color: var(--lwc-primary-light);
}

/* ============================================
   Nav Pills
   ============================================ */

.nav-pills .nav-link {
    border-radius: 8px;
    transition: var(--lwc-transition);
}

.nav-pills .nav-link.active {
    background-color: var(--lwc-primary);
    color: white;
}

.nav-pills .nav-link.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   Tabs
   ============================================ */

.nav-tabs .nav-link {
    color: var(--lwc-gray);
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    padding: 0.75rem 1.25rem;
    font-weight: 500;
    transition: var(--lwc-transition);
}

.nav-tabs .nav-link:hover {
    color: var(--lwc-primary);
    border-bottom-color: var(--lwc-gray-light);
}

.nav-tabs .nav-link.active {
    color: var(--lwc-primary);
    border-bottom-color: var(--lwc-primary);
    background: transparent;
}

/* ============================================
   Chart Containers
   ============================================ */

.chart-container {
    position: relative;
    height: 200px;
    width: 100%;
}

.chart-container canvas {
    max-height: 100%;
    max-width: 100%;
}

/* ============================================
   Loading Spinner
   ============================================ */

.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.spinner-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--lwc-primary);
}

/* ============================================
   SweetAlert2 Overrides
   ============================================ */

.swal2-popup {
    border-radius: var(--lwc-border-radius) !important;
}

.swal2-confirm {
    background-color: var(--lwc-primary) !important;
    border-radius: 25px !important;
    padding: 10px 30px !important;
}

.swal2-cancel {
    border-radius: 25px !important;
    padding: 10px 30px !important;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .lwc-header,
    .admin-header,
    .navbar,
    .admin-nav,
    .admin-sidebar,
    .btn,
    .no-print {
        display: none !important;
    }

    .lwc-card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }

    .lwc-card:hover {
        transform: none !important;
    }

    .stat-card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }

    body {
        background: white;
        display: block !important;
    }

    main,
    .admin-main {
        display: block !important;
    }

    footer,
    .admin-footer {
        display: none !important;
    }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {

    .admin-sidebar {
        margin-bottom: 1rem;
    }

    .review-sidebar {
        margin-bottom: 20px;
    }

    .review-sidebar .card {
        position: sticky;
        top: 10px;
        z-index: 100;
        max-height: 80vh;
        overflow-y: auto;
    }

    .review-sidebar .nav-pills .nav-link {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .review-sidebar .progress {
        height: 20px !important;
    }

    .review-table {
        font-size: 0.85rem;
    }

    .review-table td,
    .review-table th {
        padding: 4px 8px !important;
    }
}

/* ============================================
   MOBILE - 576px
   ============================================ */

@media (max-width: 576px) {

    .lwc-header h4 {
        font-size: 0.9rem;
    }

    .lwc-header small {
        font-size: 0.7rem;
    }

    .lwc-header img {
        max-height: 35px !important;
    }

    .lwc-header .btn-sm {
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    .admin-header {
        padding: 8px 0;
    }

    .admin-header strong {
        font-size: 0.9rem;
    }

    .admin-header .btn-sm {
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    .stat-card .number {
        font-size: 1.5rem;
    }

    .stat-card {
        padding: 12px;
    }

    .btn-lwc-primary,
    .btn-lwc-secondary {
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    .lwc-card .card-body {
        padding: 1rem;
    }

    .lwc-card .card-header {
        padding: 0.75rem 1rem;
    }

    .token-display {
        font-size: 0.8rem;
        letter-spacing: 1px;
        padding: 10px;
    }

    .navbar .nav-link {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }

    .navbar-text .badge {
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    .alert {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }

    .alert ul {
        padding-left: 1.2rem;
    }

    .progress {
        height: 18px !important;
    }

    .progress-bar {
        font-size: 0.65rem;
    }

    .modal-dialog {
        margin: 10px;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-header h5 {
        font-size: 1rem;
    }

    .review-section-card .card-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .review-section-card .card-header .btn-sm {
        font-size: 0.75rem;
        padding: 4px 10px;
    }

    .review-section-card .card-body {
        padding: 0.75rem;
    }

    footer .col-md-6,
    .admin-footer .col-md-6 {
        text-align: center !important;
    }

    footer small,
    .admin-footer small {
        font-size: 0.7rem;
    }

    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 10px;
    }

    .d-flex.justify-content-between .btn {
        width: 100%;
    }

    .d-flex.justify-content-between .btn-group {
        width: 100%;
    }

    .d-flex.justify-content-between .btn-group .btn {
        width: auto;
    }

    .form-control,
    .form-select {
        font-size: 0.9rem;
        padding: 8px 10px;
    }

    .btn {
        font-size: 0.9rem;
        padding: 8px 16px;
    }
}

/* ============================================
   Utilities
   ============================================ */

.text-lwc-primary {
    color: var(--lwc-primary);
}

.text-lwc-secondary {
    color: var(--lwc-secondary);
}

.bg-lwc-primary {
    background-color: var(--lwc-primary);
}

.bg-lwc-secondary {
    background-color: var(--lwc-secondary);
}

.border-lwc-primary {
    border-color: var(--lwc-primary);
}

.cursor-pointer {
    cursor: pointer;
}

.transition-all {
    transition: var(--lwc-transition);
}

.hover-scale:hover {
    transform: scale(1.02);
}

.hover-lift:hover {
    transform: translateY(-3px);
}

.shadow-hover:hover {
    box-shadow: var(--lwc-box-shadow-hover);
}

/* ============================================
   FORM / LAYOUT SAFETY
   ============================================ */

body > header,
body > nav,
body > main,
body > footer {
    position: relative;
}

/*
 * Prevent accidental positioning of headers/footers.
 * This is particularly important for the admin layout.
 */
body.admin-page > .admin-header {
    order: 1;
}

body.admin-page > .admin-nav {
    order: 2;
}

body.admin-page > .admin-main {
    order: 3;
}

body.admin-page > .admin-footer {
    order: 4;
}

/*
 * If the admin layout uses direct header/nav/main/footer
 * elements without the classes above, preserve the normal
 * document order rather than allowing positioning to move them.
 */
body.admin-page > header {
    flex: 0 0 auto;
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
}

body.admin-page > nav {
    flex: 0 0 auto;
    position: relative;
}

body.admin-page > main {
    flex: 1 0 auto;
    position: relative;
}

body.admin-page > footer {
    flex: 0 0 auto;
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
}
/* =========================================================
   ADMIN PAGE STRUCTURE
   ========================================================= */

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body.admin-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header MUST be first */
body.admin-page .admin-header {
    order: 1;
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100%;
    flex: 0 0 auto;
    z-index: 1000;
}

/* Navigation MUST be second */
body.admin-page .admin-nav {
    order: 2;
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100%;
    flex: 0 0 auto;
}

/* Content MUST be third */
body.admin-page .admin-main {
    order: 3;
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100%;
    flex: 1 0 auto;
}

/* Footer MUST be last */
body.admin-page .admin-footer {
    order: 4;
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100%;
    flex: 0 0 auto;
}

/* ============================================
   END OF LWC CSS
   ============================================ */
