/* ==================== Design System & Variables ==================== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200;300;400;500;600;700;800;900&display=swap');

:root {
    /* Color Palette - Modern Vibrant & Dark */
    --primary-hue: 250;
    --primary-sat: 80%;
    --primary-light: 65%;

    --primary: hsla(250, 84%, 67%, 1);
    --primary-hover: hsla(250, 84%, 57%, 1);
    --secondary: hsla(280, 84%, 60%, 1);

    --accent-success: #00ca8d;
    --accent-warning: #ffb300;
    --accent-danger: #ff5252;
    --accent-info: #00b0ff;

    /* Backgrounds */
    --bg-body: #0f111a;
    --bg-surface: rgba(30, 32, 45, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.05);

    /* Text */
    --text-main: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #718096;

    /* Spacing & Borders */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --border-light: rgba(255, 255, 255, 0.08);

    /* Sidebar */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;

    /* Shadows & Effects */
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(108, 99, 255, 0.3);
    --glass-blur: blur(20px);
}

/* ==================== Reset & Base ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-body);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(90, 80, 250, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(200, 80, 150, 0.1) 0%, transparent 40%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    line-height: 1.6;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

ul {
    list-style: none;
}

/* ==================== Layout Structure ==================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* ==================== Sidebar ==================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: rgba(20, 22, 30, 0.6);
    backdrop-filter: var(--glass-blur);
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}

.sidebar-header {
    margin-bottom: 2.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 0.5rem;
}

.brand-logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    padding-right: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    gap: 0.8rem;
    position: relative;
    overflow: hidden;
}

.nav-link i {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-link:hover i {
    transform: scale(1.1);
    color: var(--primary);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(108, 99, 255, 0.15), transparent);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.nav-link.active i {
    color: var(--primary);
}

/* ==================== Main Content ==================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header */
.top-bar {
    height: 80px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
}

.page-title h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-surface);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

/* Content Area */
.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 2rem 3rem 2rem;
}

/* ==================== Components ==================== */

/* Cards (Glassmorphism) */
.glass-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: rgba(108, 99, 255, 0.3);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-item {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.metric-item::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.03) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.metric-item:hover::after {
    opacity: 1;
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metric-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -1px;
}

.metric-value.highlight {
    background: linear-gradient(to right, #fff, #a5a5a5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 99, 255, 0.6);
}

.btn-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-main);
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}

.custom-table th {
    text-align: right;
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.custom-table td {
    background: rgba(255, 255, 255, 0.02);
    padding: 1rem;
    vertical-align: middle;
}

.custom-table tr td:first-child {
    border-top-right-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
}

.custom-table tr td:last-child {
    border-top-left-radius: var(--radius-sm);
    border-bottom-left-radius: var(--radius-sm);
}

.custom-table tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.alert-success {
    background: rgba(0, 202, 141, 0.15);
    border: 1px solid rgba(0, 202, 141, 0.3);
    color: #4ade80;
}

.alert-danger {
    background: rgba(255, 82, 82, 0.15);
    border: 1px solid rgba(255, 82, 82, 0.3);
    color: #ff8a80;
}

.alert-info {
    background: rgba(0, 176, 255, 0.15);
    border: 1px solid rgba(0, 176, 255, 0.3);
    color: #80d8ff;
}

/* Login Page Only */
.login-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 3rem;
    border-radius: var(--radius-lg);
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: 0;
        width: 100%;
        height: auto;
        bottom: 0;
        flex-direction: row;
        border-top: 1px solid var(--border-light);
        border-left: none;
        padding: 0.5rem;
        justify-content: space-around;
        align-items: center;
    }

    .sidebar-header,
    .nav-title,
    .nav-link span,
    .sidebar-logout span {
        display: none;
    }

    .nav-section {
        margin: 0;
    }

    .nav-item {
        margin: 0;
    }

    .nav-link {
        padding: 0.8rem;
        border-radius: 50%;
        justify-content: center;
    }

    .app-container {
        flex-direction: column;
    }

    .main-content {
        height: calc(100vh - 70px);
    }
}

/* ==================== GLOBAL INPUT OVERRIDES ==================== */
/* 
   Force ALL inputs (Bootstrap or otherwise) to use Premium Glass Design.
   This overrides any white background from user agent or external libraries.
*/
.glass-input,
.form-control,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
textarea,
select {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px !important;
    color: #ffffff !important;
    backdrop-filter: blur(12px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    padding: 0.8rem 1rem;
}

/* Focus State Glow */
.glass-input:focus,
.form-control:focus,
input:focus,
textarea:focus,
select:focus {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 15px rgba(108, 99, 255, 0.3), 0 0 0 2px rgba(108, 99, 255, 0.1) !important;
    transform: translateY(-2px);
    outline: none !important;
}

/* Placeholder Styling */
::placeholder,
.form-control::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
    font-weight: 300;
}

/* Form Labels */
.form-label {
    margin-bottom: 0.6rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: block;
}

/* Browser Autofill Fix (Force Dark) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
    -webkit-text-fill-color: #ffffff;
    -webkit-box-shadow: 0 0 0px 1000px #1e202d inset;
    transition: background-color 5000s ease-in-out 0s;
}

/* Select Dropdown Options */
select option {
    background-color: #1e202d;
    /* Dark background for dropdown items */
    color: white;
}