/**
 * CRIRS Tax System - Custom Styles
 * This file contains custom CSS overrides for the tax system
 */

/* ============================================
   SIDEBAR — DESKTOP COLLAPSE
   ============================================ */

/* Desktop (>= 1025px): toggled = sidebar fully hidden, header fills 100% */
@media screen and (min-width: 1025px) {

    /* Base transitions on all elements (smooth open AND close) */
    .sidebar-wrapper {
        transition: width 0.3s ease-in-out, left 0.3s ease-in-out;
    }
    .page-wrapper {
        transition: margin-left 0.3s ease-in-out, width 0.3s ease-in-out;
    }
    header, .topbar {
        transition: left 0.3s ease-in-out, width 0.3s ease-in-out;
    }

    /* Toggled: completely hide sidebar — zero width, no icon strip, nothing visible */
    .wrapper.toggled .sidebar-wrapper {
        width: 0 !important;
        min-width: 0 !important;
        overflow: hidden !important;
        left: 0 !important;
        margin-left: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        transition: width 0.3s ease-in-out;
    }

    /* Page content fills full viewport width */
    .wrapper.toggled .page-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Topbar fills full viewport width */
    .wrapper.toggled .topbar {
        left: 0 !important;
        width: 100% !important;
    }

    /* Header fills full viewport width */
    .wrapper.toggled header {
        left: 0 !important;
        width: 100% !important;
    }
}

/* ============================================
   SIDEBAR — MOBILE OVERLAY
   ============================================ */

/* Mobile (<= 1024px): sidebar slides in as overlay */
@media screen and (max-width: 1024px) {

    /* Sidebar hidden off-screen by default */
    .sidebar-wrapper {
        left: -300px !important;
        margin-left: 0 !important;
        width: 260px !important;
        height: 100vh !important;
        z-index: 99999 !important;
        transition: left 0.3s ease-in-out !important;
    }

    /* Slide in when wrapper has toggled class */
    .wrapper.toggled .sidebar-wrapper {
        left: 0 !important;
        margin-left: 0 !important;
        box-shadow: 5px 0 20px rgba(0,0,0,0.3) !important;
    }

    /* Page content stays full width on mobile */
    .page-wrapper {
        margin-left: 0 !important;
    }

    /* Topbar always full width on mobile */
    .topbar,
    header {
        left: 0 !important;
        width: 100% !important;
    }
}

/* ============================================
   TOPBAR FULL WIDTH FIX
   ============================================ */

/* Ensure navbar inside topbar always uses full available width */
.wrapper.toggled .topbar .navbar {
    padding-left: 15px;
    padding-right: 15px;
    width: 100%;
}

.wrapper.toggled .page-header {
    margin-left: 0 !important;
}

/* ============================================
   SIDEBAR TOGGLE ENHANCEMENTS
   ============================================ */

.mobile-toggle-menu {
    cursor: pointer;
    font-size: 24px;
    color: #000;
    transition: all 0.3s ease;
}

.mobile-toggle-menu:hover {
    color: #3498db;
    transform: scale(1.1);
}

.toggle-icon {
    cursor: pointer;
    font-size: 24px;
    transition: all 0.3s ease;
}

.toggle-icon i {
    transition: transform 0.3s ease;
}

.wrapper:not(.toggled) .toggle-icon i {
    transform: rotate(180deg);
}

/* ============================================
   FORM STYLING
   ============================================ */

.form-section {
    background: #fff;
    padding: 25px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.form-section:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.required::after {
    content: " *";
    color: #e74c3c;
    font-weight: bold;
}

@media (max-width: 768px) {
    .form-section {
        padding: 15px;
    }
    .section-title {
        font-size: 1.1rem;
    }
}

/* ============================================
   DASHBOARD WIDGETS
   ============================================ */

.card.radius-10 {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card.radius-10:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.widgets-icons-2 {
    transition: transform 0.3s ease;
}

.card:hover .widgets-icons-2 {
    transform: scale(1.1);
}

/* ============================================
   BUTTON ENHANCEMENTS
   ============================================ */

.btn-primary {
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

/* ============================================
   TABLE STYLING
   ============================================ */

.table-responsive {
    border-radius: 8px;
    overflow: hidden;
}

.table tbody tr {
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

/* ============================================
   ALERT STYLING
   ============================================ */

.alert {
    animation: slideInDown 0.3s ease;
    border-radius: 8px;
}

@keyframes slideInDown {
    from { transform: translateY(-20px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* ============================================
   NOTIFICATION BADGE
   ============================================ */

.alert-count {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%   { transform: scale(1);   }
    50%  { transform: scale(1.1); }
    100% { transform: scale(1);   }
}

/* ============================================
   CUSTOM SCROLLBAR
   ============================================ */

.sidebar-wrapper::-webkit-scrollbar       { width: 6px; }
.sidebar-wrapper::-webkit-scrollbar-track { background: #f1f1f1; }
.sidebar-wrapper::-webkit-scrollbar-thumb { background: #888; border-radius: 3px; }
.sidebar-wrapper::-webkit-scrollbar-thumb:hover { background: #555; }

/* ============================================
   LOADING SPINNER
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 50px; height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   FOOTER POSITIONING
   ============================================ */

.page-footer {
    margin-top: auto;
    padding: 15px 20px;
    text-align: center;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
}

.page-wrapper {
    min-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

.page-content {
    flex: 1;
}

.page-footer button,
.page-footer .btn {
    position: relative !important;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .sidebar-wrapper, header, .topbar, footer,
    .back-to-top, .btn, .overlay, .offcanvas {
        display: none !important;
    }
    .wrapper.toggled .page-wrapper,
    .page-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .page-content { padding: 0 !important; }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-primary-custom { color: #3498db !important; }
.text-muted-light    { color: #95a5a6 !important; }
.bg-light-blue       { background-color: #ecf0f1 !important; }
.mt-6                { margin-top: 4rem !important; }
.mb-6                { margin-bottom: 4rem !important; }

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

a:focus-visible, button:focus-visible,
input:focus-visible, select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.skip-to-main {
    position: absolute;
    top: -40px; left: 0;
    background: #3498db;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 10000;
}

.skip-to-main:focus { top: 0; }