/* Premium Light Corporate Theme Dashboard CSS */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --primary-color: #2563eb;
    --primary-glow: rgba(37, 99, 235, 0.15);
    --success-color: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    --danger-color: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.15);
    --warning-color: #f59e0b;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
    --topbar-height: 70px;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow-x: hidden;
    min-height: 100vh;
}

[x-cloak] {
    display: none !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Layout Structure */
.app-container {
    display: block;
    min-height: 100vh;
    position: relative;
    --active-sidebar-width: var(--sidebar-width);
}

.app-container.sidebar-is-collapsed {
    --active-sidebar-width: var(--sidebar-collapsed-width);
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.collapse-sidebar-btn {
    margin-left: auto;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.collapse-sidebar-btn:hover {
    color: var(--primary-color);
    background: #eff6ff;
}

.brand-icon {
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-name {
    font-weight: 800;
    font-size: 1.25rem;
    background: linear-gradient(to right, #0f172a, #334155);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.sidebar.collapsed .sidebar-brand {
    padding: 18px;
    justify-content: center;
}

.sidebar.collapsed .brand-name,
.sidebar.collapsed .collapse-sidebar-btn,
.sidebar.collapsed .menu-label,
.sidebar.collapsed .menu-item span,
.sidebar.collapsed .sidebar-menu > div {
    display: none !important;
}

.sidebar-menu {
    flex: 1;
    min-height: 0;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.sidebar.collapsed .sidebar-menu {
    padding: 18px 10px;
    align-items: center;
    overflow-x: hidden;
}

.menu-label {
    width: 100%;
    border: 0;
    background: transparent;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #94a3b8;
    letter-spacing: 1px;
    padding: 0 12px;
    margin-bottom: 8px;
    margin-top: 16px;
    font-family: var(--font-sans);
    font-weight: 700;
    text-align: left;
}

.menu-group-label {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.menu-group-label i {
    flex-shrink: 0;
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.menu-group {
    overflow: hidden;
    transition: all 0.2s ease;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.menu-item span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar.collapsed .menu-item {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
}

.sidebar.collapsed .menu-item.active {
    border-left: 0;
    box-shadow: inset 3px 0 0 var(--primary-color);
}

.menu-item:hover, .menu-item.active {
    color: var(--primary-color);
    background-color: #eff6ff;
}

.menu-item.active {
    background-color: #eff6ff;
    border-left: 3px solid var(--primary-color);
    font-weight: 600;
}

.menu-item i {
    font-size: 1.1rem;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.menu-item:hover i {
    transform: translateX(2px);
    color: var(--primary-color);
}

/* Main Content Area */
.main-wrapper {
    margin-left: var(--active-sidebar-width);
    width: auto;
    max-width: none;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

.topbar {
    height: var(--topbar-height);
    width: auto;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: fixed;
    top: 0;
    left: var(--active-sidebar-width);
    right: 0;
    z-index: 90;
    transition: left 0.3s ease;
}

.toggle-sidebar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Content Container */
.content-body {
    padding: 32px;
    padding-top: calc(var(--topbar-height) + 32px);
    flex: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-success {
    background-color: var(--success-color);
    color: #fff;
    box-shadow: 0 4px 14px var(--success-glow);
}

.btn-success:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-danger {
    background-color: var(--danger-color);
    color: #fff;
    box-shadow: 0 4px 14px var(--danger-glow);
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    margin-bottom: 24px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    max-width: 100%;
}

.card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Dashboard Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: #cbd5e1;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.stat-icon {
    width: 48px;
    height: 48px;
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-card:nth-child(2n) .stat-icon {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}
.stat-card:nth-child(3n) .stat-icon {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Search bar & filter wrapper */
.table-header-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.search-input-wrapper {
    position: relative;
    width: 300px;
}

.search-input-wrapper i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    padding: 10px 14px;
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
}

.search-input-wrapper .form-control {
    padding-left: 40px;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

.table th {
    padding: 16px;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-primary);
}

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

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.badge-secondary {
    background-color: #f1f5f9;
    color: var(--text-secondary);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-content {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content-lg {
    max-width: 800px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.invalid-feedback {
    color: var(--danger-color);
    font-size: 0.75rem;
    margin-top: 6px;
}

.form-control.is-invalid {
    border-color: var(--danger-color);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px var(--danger-glow);
}

/* Checkbox/Switch */
.switch-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e2e8f0;
    border: 1px solid var(--border-color);
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #94a3b8;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(20px);
    background-color: #fff;
}

/* Animations */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive Overrides */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.collapsed {
        width: var(--sidebar-width);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar.collapsed .sidebar-brand {
        padding: 24px;
        justify-content: flex-start;
    }

    .sidebar.collapsed .brand-name,
    .sidebar.collapsed .collapse-sidebar-btn,
    .sidebar.collapsed .menu-label,
    .sidebar.collapsed .menu-item span {
        display: inline-flex !important;
    }

    .sidebar.collapsed .sidebar-menu > div:not(.hidden) {
        display: block !important;
    }

    .sidebar.collapsed .menu-item {
        width: 100%;
        height: auto;
        padding: 12px 16px;
        justify-content: flex-start;
    }
    
    .main-wrapper {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }

    .sidebar.collapsed ~ .main-wrapper {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }

    .topbar {
        left: 0;
        width: 100%;
        padding: 0 16px;
    }

    .sidebar.collapsed ~ .main-wrapper .topbar {
        left: 0;
        width: 100%;
    }
    
    .toggle-sidebar-btn {
        display: inline-flex;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Collapsible menu styles */
.hidden {
    display: none !important;
}

.sidebar-menu > div {
    overflow: hidden;
    max-height: 1000px;
    transition: all 0.3s ease-in-out;
}

.sidebar-menu > div.hidden {
    display: none;
}

.menu-label {
    transition: all 0.2s ease;
}

.menu-label:hover {
    color: var(--primary-color);
}
