/* Musani Group Form 7 Management System - Custom CSS */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #0f6c82;
    --primary-dark: #0a4d5e;
    --primary-light: #e6f3f6;
    --secondary-color: #2e8b9a;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-bg: #0f172a;
    --sidebar-bg: #0b252c;
    --light-bg: #f8fafc;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --hover-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--light-bg);
    color: #1e293b;
    overflow-x: hidden;
}

/* Auth Layout styling */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0b252c 0%, #0f6c82 100%);
    position: relative;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" stroke="rgba(255,255,255,0.03)" stroke-width="1" fill="none"/></svg>') repeat;
    opacity: 0.8;
}

.auth-card {
    border: none;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.25);
    overflow: hidden;
    width: 100%;
    max-width: 440px;
    transition: all 0.3s ease;
}

.auth-card-header {
    background: var(--primary-color);
    padding: 30px 20px;
    color: white;
    text-align: center;
}

.auth-card-body {
    padding: 40px 30px;
}

/* Dashboard Layout */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

#sidebar {
    min-width: 260px;
    max-width: 260px;
    background: var(--sidebar-bg);
    color: #fff;
    transition: all 0.3s ease;
    min-height: 100vh;
    z-index: 99;
}

#sidebar .sidebar-header {
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#sidebar ul.components {
    padding: 20px 0;
}

#sidebar ul li a {
    padding: 12px 20px;
    font-size: 0.95rem;
    display: block;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

#sidebar ul li a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--secondary-color);
}

#sidebar ul li.active > a {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-left-color: var(--primary-color);
    font-weight: 500;
}

#sidebar ul li a i {
    margin-right: 10px;
    font-size: 1.1rem;
}

/* Content Area */
#content {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    transition: all 0.3s;
}

.topbar {
    background: #ffffff;
    padding: 15px 30px;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

.main-content {
    padding: 30px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Phase 7 Excel Imports Wizard Responsive Table Classes */
.imports-table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.imports-table {
    min-width: 1200px;
    width: 100%;
}

/* Custom Cards */
.stat-card {
    background: #ffffff;
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--hover-shadow);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
}

.stat-card.primary::after { background: var(--primary-color); }
.stat-card.success::after { background: var(--success-color); }
.stat-card.warning::after { background: var(--warning-color); }
.stat-card.danger::after { background: var(--danger-color); }
.stat-card.info::after { background: #3b82f6; }
.stat-card.secondary::after { background: #64748b; }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Custom Table */
.custom-table-card {
    background: #ffffff;
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 24px;
}

.custom-table th {
    background-color: var(--light-bg);
    color: #475569;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 16px;
    border: none;
}

.custom-table td {
    padding: 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

/* Searchable customer/product selects */
.search-select {
    position: relative;
    width: 100%;
}

.search-select-native {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    pointer-events: none !important;
}

.search-select-control {
    min-height: 38px;
    cursor: text;
    background: #fff;
    padding-right: 2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-select-control[readonly] {
    background: #fff;
}

.search-select::after {
    content: "\F282";
    font-family: "bootstrap-icons";
    position: absolute;
    top: 9px;
    right: 12px;
    color: #64748b;
    pointer-events: none;
    font-size: 0.8rem;
}

.search-select-menu {
    display: none;
    position: absolute;
    z-index: 1080;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgb(15 23 42 / 0.14);
}

.search-select.open .search-select-menu {
    display: block;
}

.search-select-option {
    padding: 8px 12px;
    cursor: pointer;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 0.92rem;
}

.search-select-option:hover,
.search-select-option.active {
    background: #e6f3f6;
    color: #0a4d5e;
}

.search-select-empty {
    padding: 10px 12px;
    color: #64748b;
    font-size: 0.9rem;
}

.js-report-pdf-link.disabled {
    opacity: 0.55;
    pointer-events: auto;
    cursor: not-allowed;
}

.report-export-notice {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2000;
    max-width: min(420px, calc(100vw - 36px));
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.report-export-notice.show {
    opacity: 1;
    transform: translateY(0);
}

/* Pagination must stay inside the card even after large imports create many pages. */
#paginationWrapper {
    max-width: 100%;
}

#paginationWrapper nav,
.pagination-shell {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.pagination {
    flex-wrap: wrap;
    gap: 2px;
    max-width: 100%;
}

.pagination .page-link {
    min-width: 34px;
    text-align: center;
}

/* Form Styling */
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(15, 108, 130, 0.15);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Badges */
.badge-login { background-color: var(--primary-light); color: var(--primary-color); }
.badge-logout { background-color: #f1f5f9; color: #475569; }
.badge-failed { background-color: #fee2e2; color: var(--danger-color); }

/* Print Media Styles */
@media print {
    #sidebar,
    .topbar,
    .no-print,
    .btn,
    button,
    nav,
    form,
    .pagination,
    #paginationWrapper {
        display: none !important;
    }
    #content {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    .main-content {
        padding: 0 !important;
        margin: 0 !important;
    }
    body {
        background-color: #fff !important;
        color: #000 !important;
    }
}

/* =====================================================================
   MOBILE & RESPONSIVE QA ADJUSTMENTS
   ===================================================================== */

/* Desktop Collapsed Sidebar State */
@media (min-width: 769px) {
    #sidebar.collapsed {
        min-width: 0 !important;
        max-width: 0 !important;
        overflow: hidden;
    }
}

/* Base Table Responsive Helpers */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    margin-bottom: 1rem;
    min-height: 250px; /* Space for actions dropdown overflow */
}

/* Specific Minimum Width limits for horizontal scrolling tables */
.responsive-data-table {
    min-width: 900px !important;
}

.report-table {
    min-width: 1200px !important;
}

/* Horizontal scrolling tabs for mobile navigation cards */
.mobile-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
}
.mobile-tabs .nav-item {
    flex: 0 0 auto !important;
}
.mobile-tabs::-webkit-scrollbar {
    height: 4px;
}
.mobile-tabs::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

/* Company Switcher dropdown text truncation */
.company-switch-btn {
    max-width: 250px;
}

.company-name-text {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

@media (max-width: 992px) {
    .topbar {
        padding: 12px 20px;
    }
    .main-content {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    /* Mobile Off-Canvas Sidebar Menu Drawer */
    #sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100vh;
        overflow-y: auto;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.15);
        z-index: 1050;
        min-height: 100vh;
    }
    
    #sidebar.active {
        left: 0;
    }

    /* Dark Overlay Backdrop behind sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(15, 23, 42, 0.6);
        z-index: 1040;
        display: none;
        backdrop-filter: blur(2px);
        transition: all 0.3s ease;
    }
    
    .sidebar-overlay.active {
        display: block;
    }

    /* Wrap flex rows on mobile */
    .row > [class*="col-"] {
        margin-bottom: 12px;
    }
    .row > [class*="col-"]:last-child {
        margin-bottom: 0;
    }

    .topbar {
        padding: 10px 15px;
    }

    .main-content {
        padding: 15px;
    }

    /* Truncate text tighter under mobile topbars */
    .company-switch-btn {
        max-width: 180px;
    }
    .company-name-text {
        max-width: 90px;
    }

    /* Ensure modals scale cleanly and fit small viewport sizes */
    .modal-dialog {
        margin: 10px auto;
        max-width: 95% !important;
    }
    .modal-content {
        border-radius: 12px;
    }
    .modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
    }
    .modal-footer .btn {
        width: 100%;
        margin: 0 !important;
    }
}

@media (max-width: 576px) {
    /* Reduce header sizing rules on mobiles */
    h1, .page-title, h3 {
        font-size: 1.35rem !important;
    }
    h2 {
        font-size: 1.2rem !important;
    }
    h4 {
        font-size: 1.1rem !important;
    }
    h6, .card-title {
        font-size: 0.95rem !important;
    }

    .card {
        border-radius: 12px !important;
    }

    /* Stack header action buttons */
    .page-actions, .col-sm-6.text-end, .text-end {
        text-align: left !important;
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    
    .page-actions .btn, .col-sm-6.text-end .btn, .text-end .btn {
        width: 100% !important;
        margin-top: 8px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        display: block;
    }
    
    /* Filters Stack configurations */
    .responsive-filter-grid {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .responsive-filter-grid .btn {
        width: 100%;
    }
}
