:root {
    --primary-color: #f97316;     /* Orange 500 */
    --secondary-color: #475569;   /* Slate 600 */
    --success-color: #16a34a;     /* Green 600 */
    --warning-color: #ea580c;     /* Orange 600 */
    --danger-color: #dc2626;      /* Red 600 */
    --info-color: #0284c7;        /* Light Blue 600 */
    --light-color: #f8fafc;       /* Slate 50 */
    --dark-color: #0f172a;        /* Slate 900 */
    --body-bg: #f1f5f9;           /* Slate 100 */
    --card-bg: #ffffff;
    --sidebar-bg: #0f172a;        /* Darker Sidebar */
    --sidebar-color: #94a3b8;     /* Slate 400 */
    --sidebar-hover-bg: #1e293b;  /* Slate 800 */
    --sidebar-active-bg: #f97316; /* Primary Orange */
    --sidebar-active-color: #ffffff;
    
    --font-family-base: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--body-bg);
    font-family: var(--font-family-base);
    color: var(--dark-color);
    margin: 0;
    overflow-x: hidden;
}

/* Master Layout Grid */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    min-height: 100vh;
}

/* Sidebar Styling */
#sidebar {
    min-width: 260px;
    max-width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
}

#sidebar.collapsed {
    min-width: 80px;
    max-width: 80px;
}

#sidebar .sidebar-header {
    padding: 10px 15px;
    background: var(--dark-color);
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    overflow: hidden;
}

.sidebar-logo {
    max-height: 100px;
    width: 100%;
    max-width: 230px;
    object-fit: contain;
    transition: all 0.3s ease;
}

#sidebar.collapsed .sidebar-header {
    height: 70px;
    padding: 10px;
}

#sidebar.collapsed .sidebar-logo {
    max-height: 50px;
    max-width: 60px;
}

.login-logo-container {
    text-align: center;
    margin-bottom: 25px;
}

.login-logo {
    max-width: 180px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
    transition: transform 0.3s ease;
}

.login-logo:hover {
    transform: scale(1.05);
}

#sidebar ul.components {
    padding: 15px 0;
    flex-grow: 1;
    overflow-y: auto;
}

#sidebar ul li a {
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    color: var(--sidebar-color);
    text-decoration: none;
    transition: all 0.2s ease;
    gap: 15px;
    border-left: 4px solid transparent;
}

#sidebar ul li a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

#sidebar ul li a span {
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

#sidebar.collapsed ul li a span {
    opacity: 0;
    width: 0;
    display: none;
}

#sidebar ul li a:hover {
    color: #fff;
    background: var(--sidebar-hover-bg);
}

#sidebar ul li.active > a {
    color: #fff;
    background: var(--sidebar-active-bg);
    border-left-color: #fff;
}

/* Page Content */
#content {
    flex-grow: 1;
    min-width: 0; /* Important for flex child to not overflow */
    background-color: var(--body-bg);
    display: flex;
    flex-direction: column;
}

/* Top Navbar - Sticky & Glassmorphism */
.top-navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0 24px;
    height: 64px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.main-content-body {
    padding: 24px;
    flex-grow: 1;
}

/* Sidebar Toggle Buttons */
.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--secondary-color);
    font-size: 1.25rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: rgba(0,0,0,0.05);
    color: var(--primary-color);
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    background: var(--card-bg);
    margin-bottom: 20px;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-weight: 600;
    padding: 12px 18px;
}

/* Dashboard Stats Cards */
.stat-card {
    padding: 15px;
    border-radius: 8px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.stat-card h3 {
    font-size: 1.75rem;
    margin: 0;
    font-weight: 700;
}

.stat-card p {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.8;
}

.stat-card i {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: 0.2;
}

.bg-primary-grad { background: linear-gradient(135deg, var(--primary-color), #fb923c); }
.bg-success-grad { background: linear-gradient(135deg, var(--success-color), #22c55e); }
.bg-warning-grad { background: linear-gradient(135deg, var(--warning-color), #f97316); }
.bg-danger-grad { background: linear-gradient(135deg, var(--danger-color), #ef4444); }

/* Tables */
.table {
    margin-bottom: 0;
}

.table th {
    border-top: none;
    background: #f8fafc;
    color: var(--secondary-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 8px 12px;
}

.table td {
    vertical-align: middle;
    padding: 8px 12px;
    border-top: 1px solid #f1f5f9;
}

/* Badges for status/priority */
.badge {
    padding: 6px 10px;
    border-radius: 4px;
    font-weight: 500;
}

/* Dropdown Improvements */
.dropdown-menu {
    border: none;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    border-radius: 12px;
    padding: 8px;
}

.dropdown-item {
    border-radius: 8px;
    padding: 8px 16px;
    transition: all 0.2s ease;
}

.dropdown-item.text-danger:hover, 
.dropdown-item.text-danger:active, 
.dropdown-item.text-danger:focus {
    background-color: var(--danger-color) !important;
    color: #fff !important;
}

.dropdown-item.text-danger:hover i {
    color: #fff !important;
}

/* Media Queries for Mobile Responsiveness */
/* Alerts */
.alert {
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    padding: 1rem 1.25rem;
}

.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border-left: 4px solid #22c55e;
}

.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.alert-warning {
    background-color: #fffbeb;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.alert .btn-close {
    box-shadow: none !important;
    opacity: 0.4;
    padding: 1.25rem;
    transition: all 0.2s;
}

.alert .btn-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.alert i {
    font-size: 1.1rem;
}

@media (max-width: 991.98px) {
    #sidebar {
        position: fixed;
        left: -260px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
    }
    
    #sidebar.active {
        left: 0;
    }
    
    #content {
        width: 100%;
        min-width: 100%;
    }

    /* Overlay when sidebar is open on mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        top: 0;
        left: 0;
        backdrop-filter: blur(2px);
    }
    
    .sidebar-overlay.active {
        display: block;
    }

    .top-navbar {
        padding: 0 15px;
    }
}

html {
    scroll-behavior: smooth;
}

/* ── Skeleton Loader Shimmer ── */
.skeleton-row td {
    position: relative;
    overflow: hidden;
    height: 52px;
}

.skeleton-row td::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.6) 20%,
        rgba(255, 255, 255, 0.9) 60%,
        rgba(255, 255, 255, 0)
    );
    animation: shimmer 1.5s infinite;
}

.skeleton-box {
    height: 12px;
    background: #e2e8f0;
    border-radius: 4px;
    width: 80%;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

/* ── Floating Bulk Action Bar ── */
#bulkActionBar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 1060;
    background: #fff;
    border-radius: 100px;
    padding: 10px 25px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    border: 1px solid rgba(37, 99, 235, 0.2);
    display: flex !important; /* Managed by opacity/transform */
    align-items: center;
    gap: 15px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    pointer-events: none;
}

#bulkActionBar.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ── Pulse Animation ── */
.pulse-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    margin-right: 6px;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: inherit;
    border-radius: inherit;
    animation: pulse-ring 1.5s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(2.5); opacity: 0; }
}

/* ── Back to Top ── */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 45px;
    height: 45px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.3);
    cursor: pointer;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    border: none;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-5px);
    background: var(--sidebar-active-bg);
}

/* ── Row Highlighting & Selection Glow ── */
.table-hover tbody tr:hover {
    background-color: rgba(249, 115, 22, 0.03) !important;
    transition: background-color 0.2s ease;
}

.table tbody tr.row-selected {
    background-color: rgba(249, 115, 22, 0.08) !important;
}

.table tbody tr.row-selected td {
    border-top-color: rgba(249, 115, 22, 0.1);
}

/* ── Copy to Clipboard Button ── */
.btn-copy {
    padding: 2px 6px;
    font-size: 0.75rem;
    color: var(--secondary-color);
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    margin-left: 8px;
    cursor: pointer;
    transition: all 0.2s;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-copy:hover {
    color: var(--primary-color);
    background: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(249, 115, 22, 0.1);
}

.btn-copy i {
    font-size: 0.8rem;
}

.copy-success {
    color: #16a34a !important;
    border-color: #16a34a !important;
}

/* ── Global Input & Form Control Styling ── */
.form-control, .form-select, .form-check-input {
    border: 1.5px solid #e2e8f0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    border-radius: 8px;
}

.form-control:hover, .form-select:hover {
    border-color: #cbd5e1;
    background-color: #fcfcfc;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: none !important;
    outline: 0 !important;
    background-color: #fff;
}

.form-check-input:focus {
    box-shadow: none !important;
    border-color: var(--primary-color) !important;
    outline: 0 !important;
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Lift solo elements and groups only once */
.form-control:focus:not(.input-group > .form-control),
.form-select:focus:not(.input-group > .form-select),
.input-group:focus-within {
    transform: translateY(-1px);
}

/* Fix for buttons focus outline */
.btn:focus, .btn-close:focus {
    box-shadow: none !important;
    outline: 0 !important;
}

/* ── Global Placeholder Styling ── */
::placeholder {
    color: #94a3b8 !important;
    opacity: 0.6 !important;
    font-size: 0.85rem;
}

/* ── Global Input Group & Icon Interactions ── */
.input-group {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    background-color: #fff;
}

/* Consolidated Smart Lift Effect */
.form-control:focus:not(.input-group > .form-control),
.form-select:focus:not(.input-group > .form-select),
.form-control:hover:not(.input-group > .form-control),
.form-select:hover:not(.input-group > .form-select),
.input-group:focus-within,
.input-group:hover {
    transform: translateY(-1px);
}

.input-group-text {
    background-color: #f8fafc;
    border: 1.5px solid #e2e8f0;
    color: #64748b;
    transition: all 0.3s ease;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
}

/* Reset inner borders and radius for combined elements */
.input-group > .form-control,
.input-group > .input-group-text {
    border-radius: 0 !important;
    margin: 0 !important;
}

/* Round outer corners only */
.input-group > :first-child {
    border-top-left-radius: 8px !important;
    border-bottom-left-radius: 8px !important;
}

.input-group > :last-child {
    border-top-right-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
}

/* Eliminate double-borders where they meet */
.input-group > .form-control {
    border-left: none !important;
}

/* Active Group Styling */
.input-group:focus-within .input-group-text {
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
    background-color: rgba(249, 115, 22, 0.02);
}

.input-group:focus-within .form-control {
    border-color: var(--primary-color) !important;
}

/* Icon hover effect */
.input-group:hover .input-group-text,
.input-group:hover .form-control {
    border-color: #cbd5e1;
}

/* ── Theme Branding Overrides ── */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--warning-color) !important;
    border-color: var(--warning-color) !important;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

.dropdown-item.active, .dropdown-item:active {
    background-color: var(--primary-color) !important;
}

.page-link {
    color: var(--primary-color);
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Custom Scrollbar for a premium feel */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}
