/* variables and global styles */
:root {
    --primary: #1e3a8a;
    /* deep blue */
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --secondary: #10b981;
    /* emerald */
    --accent: #f59e0b;
    --bg-main: #f3f4f6;
    --bg-card: #ffffff;
    --bg-input: #f9fafb;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --topbar-bg: #ffffff;
    --table-header: #f9fafb;
    --sidebar-bg: linear-gradient(180deg, var(--primary-dark) 0%, #172554 100%);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s ease;
    --neon-glow: 0 10px 50px rgba(30, 58, 138, 0.2), 0 0 25px rgba(59, 130, 246, 0.5), 0 0 70px rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --topbar-bg: #1e293b;
    --table-header: #334155;
    --sidebar-bg: #0f172a;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --primary-light: #60a5fa;
    --neon-glow: none;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-main);
}

a {
    text-decoration: none;
    color: var(--primary-light);
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* Utilities */
.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right;
}

.font-bold {
    font-weight: 700;
}

.text-muted {
    color: var(--text-muted);
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-align: center;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: white;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #059669;
    color: white;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

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

.btn-block {
    display: block;
    width: 100%;
}

/* Form Groups */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: var(--transition);
    background-color: var(--bg-input);
    color: var(--text-main);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-light);
    background-color: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #f87171;
}

[data-theme="dark"] .alert-error {
    background-color: rgba(127, 29, 29, 0.4);
    color: #fecaca;
    border-color: #991b1b;
    backdrop-filter: blur(8px);
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #34d399;
}

[data-theme="dark"] .alert-success {
    background-color: rgba(6, 78, 59, 0.4);
    color: #d1fae5;
    border-color: #065f46;
    backdrop-filter: blur(8px);
}

/* Dashboard Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    z-index: 10;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 2rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
}

.sidebar-header p {
    font-size: 0.85rem;
    opacity: 0.8;
}

.sidebar-nav {
    padding: 1.5rem 0;
    flex-grow: 1;
}

.nav-item {
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.8);
    transition: var(--transition);
    border-left: 4px solid transparent;
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: var(--accent);
}

.nav-icon {
    width: 24px;
    margin-right: 12px;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    min-height: 100vh;
}

.main-content.full-width {
    width: 100%;
}

.topbar {
    background-color: var(--topbar-bg);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4), 0 0 40px rgba(59, 130, 246, 0.2);
    border-bottom: 2px solid var(--primary-light);
    z-index: 5;
    position: sticky;
    top: 0;
    transition: var(--transition);
}

.topbar::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-light), var(--accent), var(--primary-light), transparent);
    background-size: 200% auto;
    animation: neon-flow 3s linear infinite;
    filter: blur(1px);
}

@keyframes neon-flow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-title-custom {
    font-family: 'Inter', sans-serif;
    font-stretch: condensed;
    font-size: 1.1rem;
    white-space: nowrap;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

@media screen and (max-width: 1200px) {
    .header-title-custom {
        font-size: 0.9rem;
    }
}

@media screen and (max-width: 768px) {
    .header-title-custom {
        font-size: 0.75rem;
        letter-spacing: -0.04em;
    }
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.content-wrapper {
    padding: 2rem;
    flex-grow: 1;
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card-grid-stats {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.card-grid-main {
    grid-template-columns: 1.5fr 1fr;
}

.card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm), var(--neon-glow);
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.card:hover {
    box-shadow: var(--shadow-md), var(--neon-glow);
    transform: translateY(-3px);
}

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-info h4 {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-info h2 {
    font-size: 1.8rem;
    color: var(--text-main);
    font-weight: 700;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-input);
    color: var(--primary-light);
    font-size: 1.5rem;
}

/* Tables */
.table-container {
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm), var(--neon-glow);
    overflow-x: auto;
    margin-top: 1rem;
}

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

.table th,
.table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: var(--table-header);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.table tbody tr:hover {
    background-color: var(--table-header);
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-active {
    background-color: #d1fae5;
    color: #065f46;
}

[data-theme="dark"] .badge-active {
    background-color: #064e3b;
    color: #d1fae5;
}

.badge-inactive {
    background-color: #fee2e2;
    color: #991b1b;
}

[data-theme="dark"] .badge-inactive {
    background-color: #7f1d1d;
    color: #fecaca;
}

/* Custom Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 90%;
    max-width: 440px;
    padding: 2.5rem 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.9) translateY(30px);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .modal-content {
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .modal-title {
    color: #ffffff !important;
}

[data-theme="dark"] .modal-text {
    color: #e2e8f0 !important;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1.5rem auto;
    position: relative;
}

.modal-icon::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    animation: pulse-ring 2s infinite;
}

.modal-icon.icon-danger {
    background: #fee2e2;
    color: #ef4444;
}

.modal-icon.icon-danger::after {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
}

.modal-icon.icon-warning {
    background: #fef3c7;
    color: #f59e0b;
}

.modal-icon.icon-warning::after {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
}

.modal-icon.icon-success {
    background: #d1fae5;
    color: #10b981;
}

.modal-icon.icon-success::after {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
}

.modal-icon.icon-info {
    background: #e0e7ff;
    color: #4f46e5;
}

.modal-icon.icon-info::after {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);
}

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

    70% {
        transform: scale(1.2);
        opacity: 0;
    }

    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.75rem;
}

.modal-text {
    color: #4b5563;
    font-size: 0.95rem;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.modal-actions .btn {
    flex: 1;
    padding: 0.75rem 0;
    font-size: 1rem;
}

.btn-cancel {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-cancel:hover {
    background: var(--bg-main);
    transform: translateY(-2px);
}

/* Tom Select Styling */
.ts-control {
    padding: 0.75rem 1rem !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 0.95rem !important;
    background-color: var(--bg-input) !important;
    color: var(--text-main) !important;
    box-shadow: none !important;
    transition: var(--transition) !important;
}

.ts-control.focus {
    border-color: var(--primary-light) !important;
    background-color: white !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
}

.ts-wrapper.single .ts-control::after {
    border-color: var(--text-muted) transparent transparent transparent !important;
}

.ts-dropdown {
    border-radius: 8px !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 0.95rem !important;
    margin-top: 4px !important;
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
}

.ts-dropdown .option {
    padding: 0.5rem 1rem !important;
}

.ts-dropdown .option.active {
    background-color: var(--table-header) !important;
    color: var(--primary-light) !important;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 1.5rem;
    padding: 1rem;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 8px;
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.page-link:hover {
    background-color: var(--bg-input);
    border-color: var(--primary-light);
    color: var(--primary-light);
}

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

/* Responsive Styles */
@media screen and (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
}

@media screen and (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
    }

    .sidebar.active {
        transform: translateX(280px);
    }

    .main-content {
        flex: 1;
        min-width: 0;
        width: 100%;
    }

    /* Reduce Neon Glow intensity for Mobile to prevent overlap visual noise */
    :root {
        --neon-glow: 0 5px 15px rgba(59, 130, 246, 0.15);
    }

    .topbar {
        padding: 0.5rem 1rem;
        height: 60px;
        gap: 10px;
    }

    .topbar-left {
        gap: 10px;
        overflow: hidden;
    }

    .page-title {
        font-size: 0.8rem;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }

    .menu-toggle-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: var(--primary);
        color: white;
        width: 38px;
        height: 38px;
        border-radius: 8px;
        cursor: pointer;
        font-size: 1.4rem;
        flex-shrink: 0;
    }

    /* Dashboard Header Responsive */
    .dashboard-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
        margin-bottom: 2rem !important;
    }

    .dashboard-header-right {
        align-self: flex-start;
        width: auto !important;
    }

    .content-wrapper {
        padding: 1.25rem 1rem;
    }

    .card-grid,
    .card-grid-stats,
    .card-grid-main {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.25rem;
    }

    .card {
        width: 100% !important;
        margin: 0 !important;
    }

    /* Sidebar Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(4px);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .user-menu {
        gap: 8px;
    }

    .user-menu span {
        display: none;
        /* Hide names on very small screens to save space */
    }

    .stat-card {
        padding: 1.25rem !important;
    }

    /* Table responsivitas */
    .table-container {
        border-radius: 12px;
        margin-top: 0.5rem;
    }

    .table th,
    .table td {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
}

/* Utils for JS Toggle */
.sidebar-locked {
    overflow: hidden;
}