@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #246196;
    --primary-hover: #1b4a72;
    --secondary: #77a044;
    --bg: #0a0f1d;
    --card-bg: rgba(16, 24, 48, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --success: #63d390;
    --error: #f87171;
    --warning: #fbbf24;
    --input-bg: rgba(255, 255, 255, 0.05);
    --hover-bg: rgba(255, 255, 255, 0.08);
    --sidebar-width: 260px;
    --header-height: 70px;
}

:root.theme-light {
    --bg: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 0, 0, 0.08);
    --text: #1e293b;
    --text-muted: #64748b;
    --input-bg: rgba(0, 0, 0, 0.03);
    --hover-bg: rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(36, 97, 150, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(119, 160, 68, 0.08) 0%, transparent 40%);
    line-height: 1.5;
}

#app {
    display: flex;
    min-height: 100vh;
}

/* Auth Page */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
}

.auth-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 2.5rem;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 10px 15px -3px rgba(36, 97, 150, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(36, 97, 150, 0.4);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--hover-bg);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 900;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Mobile Nav Toggle */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 0 1.5rem;
    align-items: center;
    justify-content: space-between;
    z-index: 900;
}

.menu-toggle {
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--glass-border);
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
}

.sidebar-logo .icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #ffffff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
    font-weight: 500;
    cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(36, 97, 150, 0.1);
    color: var(--primary);
}

.nav-item.logout {
    margin-top: auto;
    color: #fca5a5;
}

.nav-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: calc(var(--header-height) + 2rem) 3rem 2rem;
    max-width: calc(100vw - var(--sidebar-width));
    transition: all 0.3s ease;
}

/* Top Header */
.top-header {
    position: fixed;
    top: 0;
    right: 0;
    width: calc(100vw - var(--sidebar-width));
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height);
    padding: 0 3rem;
    background: var(--bg);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(10, 15, 29, 0.85);
}

:root.theme-light .top-header {
    background: rgba(241, 245, 249, 0.85);
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.top-header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: auto;
}

.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.logout-btn-compact {
    border: none !important;
    background: transparent !important;
    color: #fca5a5 !important;
}

.logout-btn-compact:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: var(--error) !important;
}

:root.theme-light .logout-btn-compact {
    color: var(--error) !important;
}

.mobile-only-item {
    display: none !important;
}



@media (max-width: 1024px) {
    .sidebar {
        left: -100%;
        width: 280px;
    }

    .sidebar.active {
        left: 0;
    }

    .mobile-only-item {
        display: flex !important;
    }

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: calc(var(--header-height) + 1.5rem) 1.25rem 2rem;
        max-width: 100vw;
    }

    .top-header {
        display: none;
        /* Hide desktop top header on mobile since elements are moved to mobile-nav */
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header h2 {
        font-size: 1.25rem;
    }

    .header .btn-primary {
        width: 100% !important;
    }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 1.25rem;
    backdrop-filter: blur(8px);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

/* Tables */
.table-container {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    overflow: visible;
    /* Changed from hidden to show dropdowns */
    backdrop-filter: blur(8px);
}

/* Responsive Tables */
@media (max-width: 768px) {
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    .table-footer {
        flex-direction: column;
        gap: 1.25rem;
        padding: 1.25rem 1rem;
        text-align: center;
    }

    .table-pagination {
        gap: 0.5rem;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .table-pagination select {
        width: 100%;
        margin-bottom: 0.25rem;
    }

    .table-pagination {
        gap: 0.35rem;
    }

    .page-link {
        min-width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem 1.5rem;
    background: var(--input-bg);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.875rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--input-bg);
}

.badge {
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* Inputs */
input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: var(--text);
    transition: all 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--hover-bg);
    box-shadow: 0 0 0 4px rgba(36, 97, 150, 0.1);
}

select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: var(--text);
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--hover-bg);
    box-shadow: 0 0 0 4px rgba(36, 97, 150, 0.1);
}

select option {
    background: var(--bg);
    color: var(--text);
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.form-col {
    flex: 1;
}

.form-row .form-group {
    margin-bottom: 0;
    flex: 1;
}

/* Action Buttons */
.icon-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--hover-bg);
    color: var(--text);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 600px;
    transform: translateY(20px);
    transition: all 0.3s;
}

@media (max-width: 640px) {
    .modal {
        padding: 1.5rem;
        max-width: 90vw;
    }
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal i.fas {
    filter: drop-shadow(0 0 15px rgba(0, 0, 0, 0.2));
}

.pulse-animation {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.btn-danger {
    background: linear-gradient(135deg, var(--error), #dc2626) !important;
    box-shadow: 0 10px 15px -3px rgba(220, 38, 38, 0.3) !important;
}

.btn-danger:hover {
    box-shadow: 0 20px 25px -5px rgba(220, 38, 38, 0.4) !important;
}

/* Loading Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.active {
    transform: translateX(0);
}

/* Navigation Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 800;
}

.sidebar-overlay.active {
    display: block;
}

/* Table Footer & Pagination */
.table-footer {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--input-bg);
    border-top: 1px solid var(--glass-border);
}

.table-info {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.table-pagination {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.table-pagination select {
    background-color: var(--bg);
    color: var(--text);
    border: 1px solid var(--glass-border);
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    outline: none;
    cursor: pointer;
}

.table-pagination select option {
    background-color: var(--bg);
    color: var(--text);
}

.table-pagination button {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.table-pagination button:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
}

.table-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-numbers {
    display: flex;
    gap: 0.35rem;
}

.page-link {
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    transition: all 0.2s;
}

.page-link:hover:not(.active) {
    background: var(--hover-bg);
    color: var(--primary);
}

.page-link.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Profiles Section */
.profile-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.app-footer {
    padding: 1.5rem 0 1.5rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.8125rem;
    border-top: 1px solid var(--glass-border);
    margin-top: 4rem;
}

.app-footer strong {
    color: var(--primary);
}

/* Action Dropdown */
.action-dropdown {
    position: relative;
    display: inline-block;
}

.action-menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: #1a2236;
    /* Solid background for Dark Mode */
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    min-width: 170px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    z-index: 9999;
    /* Max z-index */
    display: none;
    overflow: hidden;
}

:root.theme-light .action-menu {
    background: #ffffff;
    /* Solid white for Light Mode */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}


.action-menu.active {
    display: block;
    animation: dropdownShow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownShow {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.action-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: left;
    width: 100%;
    background: transparent;
    border: none;
}

.action-item:hover {
    background: var(--hover-bg);
    color: var(--primary);
}

.action-item i {
    width: 16px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.action-item.delete:hover {
    color: var(--error);
    background: rgba(248, 113, 113, 0.1);
}