/* ==========================================================================
   CEN360 ERP - OFFICIAL GLOBAL THEME DESIGN (PAYROLL ENGINE STANDARD)
========================================================================== */

:root { 
    /* Core Branding Colors */
    --centribe-blue: #0d2b52; 
    --centribe-hover: #1a4480; 
    
    /* Global Semantic Colors */
    --cen-bg-main: #ffffff;
    --cen-bg-alt: #fafbfe;
    --cen-border: #eaeaea;
    --cen-text-main: #333333;
    --cen-text-muted: #6c757d;
    
    /* Status Colors */
    --cen-success: #198754;
    --cen-danger: #dc3545;
    --cen-warning: #ffc107;
    --cen-info: #0dcaf0;

    /* Global Measurements */
    --cen-radius: 6px;
    --cen-transition: all 0.3s ease-in-out;
}

/* ==========================================
   GLOBAL ANTI-COPY, SIZING & SELECTION SHIELD
========================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body { 
    background-color: var(--cen-bg-main); 
    font-family: 'Segoe UI', Tahoma, sans-serif; 
    overflow-x: hidden; 
    margin: 0; 
    color: var(--cen-text-main); 
    -webkit-user-select: none; 
    -moz-user-select: none; 
    -ms-user-select: none; 
    user-select: none; 
    -webkit-touch-callout: none; 
}

input, textarea, select { 
    -webkit-user-select: auto; 
    -moz-user-select: auto; 
    -ms-user-select: auto; 
    user-select: auto; 
}

/* PREMIUM SCROLLBARS FOR ERP FEEL */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

#app-wrapper { 
    display: flex; 
    width: 100vw; 
    height: 100vh; 
    overflow: hidden; 
    background-color: var(--cen-bg-main); 
}

/* ==========================================
   SMART ADAPTABLE SIDEBAR
========================================== */
#sidebar-wrapper { 
    width: max-content; 
    min-width: 230px; 
    max-width: 400px; 
    background-color: var(--centribe-blue); 
    color: white; 
    display: flex; 
    flex-direction: column; 
    transition: var(--cen-transition); 
    z-index: 1050; 
    overflow-y: auto; 
    overflow-x: hidden; 
    white-space: nowrap; 
    flex-shrink: 0; /* Prevent sidebar from shrinking */
}

#sidebar-wrapper.collapsed { 
    min-width: 0; 
    max-width: 0; 
    opacity: 0; 
    padding: 0; 
    margin: 0; 
    border: none; 
}

.sidebar-heading { 
    padding: 1.5rem 1rem; 
    font-size: 1.2rem; 
    font-weight: bold; 
    text-align: center; 
    border-bottom: 1px solid rgba(255,255,255,0.05); 
}

/* MAIN NAV BUTTONS */
.nav-link-btn { 
    background-color: transparent; 
    color: #ced4da; 
    border: none; 
    padding: 15px 25px; 
    font-weight: 600; 
    font-size: 13px; 
    text-transform: uppercase; 
    transition: all 0.2s; 
    cursor: pointer; 
    text-align: left; 
    width: 100%; 
    border-left: 4px solid transparent; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}

.nav-link-btn:hover { 
    background-color: var(--centribe-hover); 
    color: white; 
}

.nav-link-btn.active { 
    background-color: var(--cen-bg-main); 
    color: var(--centribe-blue); 
    border-left: 4px solid var(--centribe-blue); 
    font-weight: bold; 
}

.nav-link-btn .chevron-icon { 
    transition: transform 0.3s ease; 
    font-size: 10px; 
    opacity: 0.5; 
}

.nav-link-btn:not(.collapsed) .chevron-icon { 
    transform: rotate(180deg); 
}

/* SIDEBAR SUB-MENUS (ACCORDION STYLE) */
.sub-menu-container { 
    background-color: rgba(0,0,0,0.15); 
    border-left: 2px solid rgba(255,255,255,0.05); 
}

.sub-menu-btn { 
    background-color: transparent; 
    color: #a8b2bc; 
    border: none; 
    padding: 12px 25px 12px 45px; 
    font-weight: 500; 
    font-size: 11px; 
    text-transform: uppercase; 
    transition: all 0.2s; 
    cursor: pointer; 
    text-align: left; 
    width: 100%; 
    display: block; 
    border-left: 3px solid transparent; 
}

.sub-menu-btn:hover { 
    color: white; 
    background-color: rgba(255,255,255,0.05); 
}

.sub-menu-btn.active-sub { 
    color: #ffffff; 
    font-weight: bold; 
    border-left: 3px solid var(--cen-warning); 
    background-color: rgba(255,255,255,0.05); 
}

/* CONTENT AREA & BULLETPROOF FLEX CONTAINMENT */
#page-content-wrapper { 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    justify-content: flex-start; /* CRITICAL FIX: Forces content to snap to the top, eliminating vertical blank spaces */
    align-items: stretch;
    overflow-y: auto; 
    overflow-x: hidden; 
    background-color: var(--cen-bg-main); 
    transition: var(--cen-transition); 
    min-width: 0; /* CRITICAL: Prevents flex children from stretching screen */
    width: 100%;
}

/* MAIN MODULE MOUNT POINT (SPACING FIX) */
#module-mount-point {
    padding: 15px 25px !important; /* Compact padding to pull modules upward */
    margin-top: 0 !important; /* Eliminates huge top space */
    width: 100%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* CRITICAL FIX: Stops module content from centering vertically */
}

.tab-content, .tab-pane {
    width: 100%;
    max-width: 100%;
    min-width: 0; /* CRITICAL: Prevents inner modules from blowing out */
}

/* ==========================================
   TOP NAVBAR (FROZEN / STICKY HEADER)
========================================== */
.top-navbar { 
    background-color: var(--cen-bg-main); 
    border-bottom: 1px solid var(--cen-border); 
    padding: 10px 25px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    z-index: 999; 
    position: sticky; 
    top: 0; 
}

#toggle-sidebar-btn { 
    background: transparent; 
    border: none; 
    font-size: 1.5rem; 
    color: var(--centribe-blue); 
    cursor: pointer; 
    margin-right: 15px; 
}

.profile-circle { 
    width: 38px; 
    height: 38px; 
    border-radius: 50%; 
    object-fit: cover; 
    border: 2px solid var(--centribe-blue); 
    cursor: pointer; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
}

.dropdown-menu-end { right: 0; left: auto; }

/* ==========================================
   CEN360 OFFICIAL UI COMPONENTS
========================================== */

/* 1. Typography & Forms */
.hidden { display: none !important; }

.form-label { 
    font-weight: bold; 
    font-size: 11px; 
    color: var(--cen-text-muted); 
    margin-bottom: 4px; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
}

.form-control, .form-select { 
    font-size: 13px !important; 
    padding: 6px 10px !important; 
    min-height: 32px !important; 
    border-radius: var(--cen-radius) !important; 
    border: 1px solid #e1e5eb !important; 
    background-color: var(--cen-bg-alt); 
    box-shadow: none !important; 
    transition: var(--cen-transition);
}

.form-control:focus, .form-select:focus { 
    border-color: var(--centribe-blue) !important; 
    background-color: var(--cen-bg-main); 
    outline: 0; 
}

.form-control-plaintext {
    transition: var(--cen-transition);
    border-radius: var(--cen-radius) !important;
}

/* 2. Minimalist Tabs */
.nav-tabs { 
    border-bottom: 2px solid var(--cen-border); 
    gap: 10px; 
    padding-left: 5px; 
    border-radius: 0; 
}

.nav-tabs .nav-link { 
    background: transparent; 
    border: none; 
    border-bottom: 2px solid transparent; 
    color: #8c98a4; 
    font-weight: 600; 
    font-size: 12px; 
    text-transform: uppercase; 
    padding: 10px 15px; 
    margin-bottom: -2px; 
    border-radius: 0; 
    transition: all 0.2s; 
}

.nav-tabs .nav-link.active { 
    color: var(--centribe-blue); 
    background-color: transparent; 
    border-bottom: 2px solid var(--centribe-blue); 
}

.nav-tabs .nav-link:hover:not(.active) { 
    color: var(--centribe-blue); 
    border-bottom: 2px solid #dcdcdc; 
    background-color: transparent; 
}

/* 3. Containers & Cards */
.bg-light { background-color: #fdfdfd !important; border: 1px solid #f0f0f0; }
.shadow-sm, .shadow { box-shadow: none !important; }

.glass-card { 
    background: var(--cen-bg-main); 
    border: 1px solid var(--cen-border); 
    border-radius: var(--cen-radius); 
    min-width: 0; /* Flex fix */
    max-width: 100%;
}

.card { 
    border: 1px solid var(--cen-border); 
    border-radius: var(--cen-radius); 
    box-shadow: none !important; 
    min-width: 0;
}

.card-icon-large { 
    font-size: 2.5rem; 
    color: var(--centribe-blue); 
    margin-bottom: 15px; 
}

.history-box { 
    background-color: var(--cen-bg-main); 
    border: 1px solid var(--cen-border); 
    border-radius: 4px; 
    padding: 10px; 
    font-size: 12px; 
    white-space: pre-wrap; 
    font-family: monospace; 
}

/* 4. Official Buttons */
.btn-cen360 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 6px 14px;
    border-radius: 4px;
    transition: var(--cen-transition);
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-cen360-primary {
    background-color: var(--centribe-blue);
    color: white;
}

.btn-cen360-primary:hover {
    background-color: var(--centribe-hover);
    color: white;
}

.btn-cen360-secondary {
    background-color: var(--cen-bg-alt);
    color: var(--cen-text-main);
    border: 1px solid var(--cen-border);
}

.btn-cen360-secondary:hover {
    background-color: #e2e6ea;
}

/* 5. Official Data Tables & Responsiveness */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}

.table-cen360 {
    width: 100%;
    margin-bottom: 1rem;
    vertical-align: middle;
    font-size: 13px;
    min-width: 600px; /* Ensures tables don't compress into unreadable columns */
}

.table-cen360 thead th {
    background-color: var(--cen-bg-alt);
    color: var(--cen-text-muted);
    font-weight: bold;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 15px;
    border-bottom: 2px solid var(--cen-border);
    border-top: none;
}

.table-cen360 tbody td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--cen-border);
    color: var(--cen-text-main);
}

.table-cen360 tbody tr:hover {
    background-color: rgba(13, 43, 82, 0.03); 
}

/* 6. Official Status Badges */
.badge-cen360 {
    padding: 4px 8px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: 12px;
    letter-spacing: 0.5px;
}
.badge-success { background-color: rgba(25, 135, 84, 0.1); color: var(--cen-success); }
.badge-warning { background-color: rgba(255, 193, 7, 0.15); color: #d39e00; }
.badge-danger { background-color: rgba(220, 53, 69, 0.1); color: var(--cen-danger); }
.badge-primary { background-color: rgba(13, 43, 82, 0.1); color: var(--centribe-blue); }


/* ==========================================================================
   KANBAN CRM PIPELINE (HARDENED RESPONSIVENESS)
========================================================================== */
.kanban-board { 
    display: flex; 
    gap: 1rem; 
    overflow-x: auto; 
    padding-bottom: 1rem; 
    min-height: 65vh; 
    width: 100%;
    align-items: stretch;
}

.kanban-col { 
    min-width: 320px; 
    width: 320px; 
    background-color: #f4f5f7; 
    border-radius: 8px; 
    padding: 12px; 
    display: flex; 
    flex-direction: column; 
    flex-shrink: 0; /* CRITICAL: Stops columns from shrinking/crushing together */
}

.kanban-cards-container { 
    flex-grow: 1; 
    min-height: 150px; 
}

.cursor-grab { cursor: grab; }
.cursor-grab:active { cursor: grabbing; }

.kanban-col.drag-over { 
    background-color: #e2e4e9 !important; 
    border: 2px dashed var(--centribe-blue) !important; 
}


/* ==========================================================================
   INTERNATIONAL GRADED PAYSLIP (VIEW/PRINT UI)
========================================================================== */
.payslip-wrapper {
    font-family: Arial, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    color: #333;
    padding: 25px;
    border: 1px solid #ccc;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.payslip-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.payslip-company-info img { max-height: 60px; margin-bottom: 10px; }
.payslip-company-info h2 { font-size: 16px; font-weight: bold; margin: 0 0 5px 0; color: #333; }
.payslip-company-info p { font-size: 12px; color: #555; margin: 0; line-height: 1.4; }
.payslip-title-block { text-align: right; }
.payslip-title-block h1 { margin: 0; font-size: 32px; letter-spacing: 2px; color: #222; text-transform: uppercase; }
.payslip-period-box { margin-top: 10px; font-size: 13px; background: #f4f6f8; padding: 8px 12px; border: 1px solid #ddd; display: inline-block; text-align: left; }
.payslip-emp-details { width: 100%; font-size: 11px; border-collapse: collapse; margin-bottom: 20px; border: 1px solid #ddd; }
.payslip-emp-details td { padding: 6px 8px; border: 1px solid #ddd; }
.payslip-emp-details tr:nth-child(odd) { background-color: #f9f9f9; }
.payslip-body { display: flex; gap: 15px; margin-bottom: 15px; }
.payslip-col { flex: 1; display: flex; flex-direction: column; }
.payslip-table { width: 100%; font-size: 11px; border-collapse: collapse; border: 1px solid #ccc; }
.payslip-table th { background-color: #e9ecef; padding: 6px 8px; border: 1px solid #ccc; font-weight: bold; text-align: left; }
.payslip-table th.right, .payslip-table td.right { text-align: right; }
.payslip-table td { padding: 6px 8px; border: 1px solid #ccc; }
.payslip-table tr.section-title td { background-color: #fdfdfd; font-weight: bold; border-top: 2px solid #ddd; }
.payslip-table tr.subtotal td { background-color: #f4f6f8; font-weight: bold; }
.payslip-table tr.gross-total td { background-color: #d1e7dd; font-size: 13px; font-weight: bold; }
.payslip-table tr.deduct-total td { background-color: #f8d7da; font-size: 13px; font-weight: bold; }
.payslip-net-block { width: 100%; border-collapse: collapse; border: 1px solid #0d6efd; margin-top: 10px; }
.payslip-net-block td { background-color: #cfe2ff; padding: 12px 15px; text-align: right; }
.payslip-net-title { font-size: 16px; font-weight: bold; width: 80%; }
.payslip-net-amount { font-size: 20px; font-weight: bold; width: 20%; }
.payslip-footer { font-size: 10px; color: #777; margin-top: 15px; text-align: center; line-height: 1.4; }


/* ==========================================================================
   MOBILE RESPONSIVENESS BREAKPOINTS
========================================================================== */
@media (max-width: 768px) {
    /* Auto-collapse/overlay Sidebar on mobile */
    #sidebar-wrapper {
        position: fixed;
        height: 100vh;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        box-shadow: 5px 0 15px rgba(0,0,0,0.2);
    }
    
    #sidebar-wrapper:not(.collapsed) {
        transform: translateX(0);
        min-width: 250px;
    }

    /* Stack flex boxes on mobile */
    .payslip-body { flex-direction: column; }
    
    /* Make padding more forgiving on small devices */
    .glass-card { padding: 1rem !important; }
    #module-mount-point { padding: 10px !important; }
}

/* 
   =================================
   PRINT MEDIA QUERY FOR PDF & PAPER
   =================================
*/
@media print {
    body * { visibility: hidden; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    #payslipPrintContainer, #payslipPrintContainer * { visibility: visible; }
    #payslipPrintContainer { position: absolute; left: 0; top: 0; width: 100%; margin: 0; padding: 0; }
    .payslip-wrapper { border: none; box-shadow: none; padding: 0; max-width: 100%; width: 100%; }
    .modal-backdrop, .btn, button, .modal-header .btn-close { display: none !important; }
}