

/* --- Variables & Themes --- */
:root {
    --bg-main: #121212;
    --bg-surface: #1e1e1e;
    --bg-sidebar: #181818;
    --text-main: #e0e0e0;
    --text-dim: #a0a0a0;
    --accent: #bb86fc;
    --border: #333;
    --hover: #2a2a2a;
    --shadow: rgba(0,0,0,0.5);
}

[data-theme="light"] {
    --bg-main: #f8f9fa;
    --bg-surface: #ffffff;
    --bg-sidebar: #ffffff;
    --text-main: #2d3436;
    --text-dim: #636e72;
    --accent: #6c5ce7;
    --border: #e1e4e8;
    --hover: #f1f2f6;
    --shadow: rgba(0,0,0,0.05);
}

@font-face {
  font-family: 'Poppins';
  src: url('fonts/poppins_regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'retron2000';
  src: url('fonts/retron2000.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
}
::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background-color: var(--border);
}

/* --- Base Styles --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background 0.3s, color 0.3s;
}

/* Ensure the body doesn't scroll behind the modal */
body.modal-open {
    overflow: hidden;
    padding-right: 15px; /* Prevents layout shift when scrollbar disappears */
}

/* --- Top Bar --- */
.top-bar {
    height: 65px;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1001;
}

.header-left, .header-right { display: flex; align-items: center; }
.logo { font-weight: 600; font-size: 1.4rem; color: var(--text-main); }
.logo span { color: var(--accent); }

.menu-btn {
    background: none; border: none; color: var(--text-main);
    font-size: 1.5rem; cursor: pointer; display: none; margin-right: 15px;
}

.theme-btn {
    background: none; border: 1px solid var(--border);
    padding: 5px 8px; border-radius: 8px; cursor: pointer; margin-right: 20px;
}

/* --- Sidebar --- */
.container { display: flex; }
.sidebar {
    width: 260px; height: calc(100vh - 65px);
    background: var(--bg-sidebar); border-right: 1px solid var(--border);
    padding: 20px 10px; transition: transform 0.3s ease;
}

.nav-list { list-style: none; }
.nav-link, .sidebar-link-wrapper {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 15px; color: var(--text-main); text-decoration: none;
    border-radius: 10px; cursor: pointer; transition: 0.2s;
}
.nav-link:hover, .sidebar-link-wrapper:hover { background: var(--hover); }

/* --- Collapsible --- */
.submenu { 
    /*display: none; */
    list-style: none; padding-left: 20px; 
    overflow: hidden;
    /* Animation logic */
    display: grid;
    grid-template-rows: 0fr;
     Starts at 0 height 
    transition: grid-template-rows 0.3s ease-out, padding 0.3s ease;
    opacity: 0;
}
.submenu.open {
    display: block;
    /*grid-template-rows: 1fr; /* Animates to full content height */
    opacity: 1;
    padding-top: 5px;
    padding-bottom: 5px;*/
}
.collapsible.active .arrow { transform: rotate(90deg); }
.arrow { font-size: 0.8rem; transition: 0.3s; }

/* --- User Dropdown --- */
.user-menu { position: relative; }
.profile-trigger { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.avatar { width: 35px; border-radius: 50%; border: 2px solid var(--accent); }
.dropdown-content {
    display: none; position: absolute; right: 0; top: 55px;
    background: var(--bg-surface); min-width: 180px; border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 10px 30px var(--shadow);
}
.dropdown-content.show { display: block; animation: slideDown 0.2s ease; }
.dropdown-content li a { display: block; padding: 12px 20px; text-decoration: none; color: var(--text-main); }
.dropdown-content hr { border: 0; border-top: 1px solid var(--border); }

/* --- Main Content --- */
.content { flex: 1; padding: 40px; }
.card-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px; margin-top: 30px;
}
.card {
    background: var(--bg-surface); padding: 30px; border-radius: 15px;
    border: 1px solid var(--border); box-shadow: 0 4px 6px var(--shadow);
}

/* --- Mobile Drawer --- */
@media (max-width: 768px) {
    .menu-btn { display: block; }
    .user-name { display: none; }
    .sidebar {
        position: fixed; left: -260px; top: 65px; z-index: 1000;
        box-shadow: 10px 0 30px var(--shadow);
    }
    .sidebar.drawer-open { transform: translateX(260px); }
    .overlay {
        display: none; position: fixed; top: 65px; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.5); z-index: 999;
    }
    .overlay.active { display: block; }
}

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

/* Toggle Icons Logic */
[data-theme="light"] .sun-icon { display: none; }
:root:not([data-theme="light"]) .moon-icon { display: none; }


/* --- Tables --- */
.table-container {
    background: var(--bg-surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow-x: auto; /* Scroll for mobile */
    margin-top: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-sidebar);
    color: var(--text-dim);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.data-table tr:last-child td { border-bottom: none; }

/* --- Badges --- */
.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge.success { background: rgba(0, 200, 81, 0.1); color: #00c851; }
.badge.warning { background: rgba(255, 187, 51, 0.1); color: #ffbb33; }

/* --- Base Badge Style --- */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50px; /* Makes it a pill shape */
    text-transform: capitalize;
    white-space: nowrap;
    border: 1px solid transparent;
}

/* --- Badge Variations --- */
.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.badge-muted {
    background: var(--hover);
    color: var(--text-dim);
    border-color: var(--border);
}

.badge-transparent {
    background: transparent;
    color: var(--text-main);
    border-color: var(--border);
}

/* Container for spacing */
.badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

/* --- Buttons --- */
.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-secondary { background: var(--hover); color: var(--text-main); border: 1px solid var(--border); padding: 10px 20px; border-radius: 8px; cursor: pointer; }

/* Base Button Setup */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    gap: 8px;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 15px;
}

.btn:active {
    transform: scale(0.97);
}

/* Solid Variants */
.btn-success { background-color: #00c851; color: #fff; }
.btn-success:hover { background-color: #00a844; }

.btn-danger { background-color: #ff4444; color: #fff; }
.btn-danger:hover { background-color: #cc0000; }

.btn-warning { background-color: #ffbb33; color: #121212; }
.btn-warning:hover { background-color: #e6a82c; }

.btn-info { background-color: #33b5e5; color: #fff; }
.btn-info:hover { background-color: #0099cc; }

.btn-muted { background-color: var(--hover); color: var(--text-dim); border-color: var(--border); }
.btn-muted:hover { background-color: var(--border); color: var(--text-main); }

.btn-transparent { background-color: transparent; color: var(--text-main); }
.btn-transparent:hover { background-color: var(--hover); }

/* Outline Variants */
.btn-outline-success { background: transparent; border-color: #00c851; color: #00c851; }
.btn-outline-success:hover { background: #00c851; color: #fff; }

.btn-outline-danger { background: transparent; border-color: #ff4444; color: #ff4444; }
.btn-outline-danger:hover { background: #ff4444; color: #fff; }

.btn-outline-warning { background: transparent; border-color: #ffbb33; color: #ffbb33; }
.btn-outline-warning:hover { background: #ffbb33; color: #121212; }

.btn-outline-info { background: transparent; border-color: #33b5e5; color: #33b5e5; }
.btn-outline-info:hover { background: #33b5e5; color: #fff; }

/* --- Modal --- */
.modal-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active { display: flex; }

.modal-card {
    background: var(--bg-surface);
    width: 90%;
    max-width: 500px;
    padding: 30px;
    border-radius: 15px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    /* SCROLLING */
    max-height: 90vh; /* Prevents modal from going off-screen */
    display: flex;
    flex-direction: column;

    width: 100%;
    max-width: 600px;
    height: auto;            /* Allow it to grow with content */
    margin-bottom: 40px;     /* Extra spacing at the bottom */
    
    /* Remove any fixed heights or internal overflows you added earlier */
    max-height: none;

}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.close-x { background: none; border: none; font-size: 1.5rem; color: var(--text-dim); cursor: pointer; }

.modal-header, 
.modal-footer {
    flex-shrink: 0; /* Ensures header/footer don't squash */
    padding: 20px;
    background: var(--bg-surface);
}
.modal-body {
    flex-grow: 1;
    overflow-y: auto; /* This enables the scrollbar */
    padding: 0 20px 20px 20px;
    
    /* Custom Scrollbar for a cleaner look */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
/* Chrome/Safari Scrollbar Styling */
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 10px;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }

/* Form inputs inside modal */
.modal-form select, .modal-form input {
    width: 100%; padding: 10px; border-radius: 8px; 
    border: 1px solid var(--border); background: var(--bg-main); color: var(--text-main);
    font-family: inherit; margin-top: 5px;
}

.modal-overlay {
    display: none;
    display: flex;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); /* Lighter overlay so multiple stacks don't turn pure black */
    justify-content: center;
    align-items: center;
    /* This allows modals to stack based on when they were opened */
    z-index: 1000;

    /* Transition Properties */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(2px); /* Optional: adds a modern frosted glass look */
    
    align-items: flex-start; /* Aligns modal to the top */
    padding: 40px 20px;      /* Gives space at top/bottom when scrolling */
    overflow-y: auto;        /* Enables scrolling for the entire overlay */
    pointer-events: auto;

}

.modal-overlay.active {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

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

/* 2. Applying the Animation to the Image */
.spin-image {
    /* Short-hand property for:
       animation-name: spin;
       animation-duration: 4s;
       animation-timing-function: linear;
       animation-iteration-count: infinite;
    */
    animation: spin 1s linear infinite;

    /* Add some styling to make it a circle (optional) */
    /*border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);*/
}

/* --- Text Color Utilities --- */

/* Theme-Based (Dynamic) */
.text-primary   { color: var(--accent) !important; }
.text-secondary { color: var(--text-dim) !important; }
.text-muted     { color: var(--text-dim); opacity: 0.7; }
.text-main      { color: var(--text-main) !important; }

/* Status-Based (Fixed) */
.text-success   { color: #10b981 !important; } /* Emerald */
.text-danger    { color: #ef4444 !important; } /* Red */
.text-warning   { color: #f59e0b !important; } /* Amber */
.text-info      { color: #3b82f6 !important; } /* Blue */

/* Absolute Colors */
.text-white     { color: #ffffff !important; }
.text-dark      { color: #121212 !important; }
.text-light     { color: #f8f9fa !important; }

/* Optional: Hover helpers */
.text-hover-primary:hover { color: var(--accent) !important; }

/* --- Link Utilities --- */
.link {
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    font-weight: 500;
}

/* Hover effect: Subtle underline */
.link:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* --- Link Color Variations --- */
.link-primary   { color: var(--accent); }
.link-primary:hover { color: var(--accent-hover, #5a4bda); }

.link-secondary { color: var(--text-dim); }
.link-secondary:hover { color: var(--text-main); }

.link-success   { color: #10b981; }
.link-success:hover { color: #059669; }

.link-danger    { color: #ef4444; }
.link-danger:hover { color: #dc2626; }

.link-warning   { color: #f59e0b; }
.link-warning:hover { color: #d97706; }

.link-info      { color: #3b82f6; }
.link-info:hover { color: #2563eb; }

.link-muted     { color: var(--text-dim); opacity: 0.7; }
.link-muted:hover { opacity: 1; }

.link-white     { color: #ffffff; }
.link-white:hover { opacity: 0.8; }

.link-dark      { color: #121212; }
.link-dark:hover { opacity: 0.7; }

.link-light     { color: #f8f9fa; }
.link-light:hover { color: #ffffff; }

/* --- Progress Bar Container --- */
.progress-wrapper {
    margin-bottom: 20px;
    width: 100%;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
}

.progress-track {
    width: 100%;
    height: 10px;
    background: var(--hover); /* Uses theme's hover/muted color */
    border-radius: 50px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    border-radius: 50px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Color Variations --- */
.bg-primary   { background-color: var(--accent); }
.bg-secondary { background-color: var(--text-dim); }
.bg-success   { background-color: #10b981; }
.bg-danger    { background-color: #ef4444; }
.bg-warning   { background-color: #f59e0b; }
.bg-info      { background-color: #3b82f6; }
.bg-muted     { background-color: var(--border); }
.bg-dark      { background-color: #121212; }
.bg-light     { background-color: #f8f9fa; }
.bg-default   { background-color: #6c757d; }

/* Transparent variation (Outline style) */
.progress-track.is-transparent {
    background: transparent;
    border: 1px solid var(--border);
}

/* --- Switch Container --- */
.switch-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    cursor: pointer;
}

.switch-label {
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
}

/* --- The Actual Switch --- */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--hover);
    border: 1px solid var(--border);
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* --- States & Colors --- */
input:checked + .slider { background-color: var(--accent); border-color: transparent; }
input:checked + .slider:before { transform: translateX(22px); }

/* Color Variations */
input:checked + .slider-success { background-color: #10b981; }
input:checked + .slider-danger  { background-color: #ef4444; }
input:checked + .slider-warning { background-color: #f59e0b; }
input:checked + .slider-info    { background-color: #3b82f6; }
input:checked + .slider-muted   { background-color: var(--text-dim); }

/* Disabled State */
input:disabled + .slider { opacity: 0.5; cursor: not-allowed; }

