@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* ==================== CSS VARIABLES ==================== */
:root {
    /* Primary Gradient Colors */
    --gradient-primary-start: #667eea;
    --gradient-primary-end: #764ba2;
    --gradient-secondary-start: #00d2ff;
    --gradient-secondary-end: #3a7bd5;

    /* Solid Colors */
    --primary: #667eea;
    --secondary: #00d2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Dark Theme */
    --dark-bg: #1a1a2e;
    --dark-secondary: #16213e;
    --dark-accent: #0f3460;

    /* Light Colors */
    --light-bg: #f8fafc;
    --white: #ffffff;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;

    /* Spacing */
    --bottom-nav-height: 70px;
    --top-nav-height: 60px;
    --card-radius: 16px;
    --btn-radius: 12px;

    /* Shadows */
    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.4);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: var(--gray-800);
    line-height: 1.6;
    font-size: 14px;
    overflow-x: hidden;
    padding-bottom: var(--bottom-nav-height);
}

/* ==================== LOADING SCREEN ==================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--gradient-primary-start), var(--gradient-primary-end));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity var(--transition-slow);
}

.loading-screen.d-none {
    opacity: 0;
    pointer-events: none;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== TOP NAVIGATION ==================== */
.top-navbar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-nav-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gradient-primary-start), var(--gradient-primary-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-primary-start), var(--gradient-primary-end));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.user-avatar:hover {
    transform: scale(1.1);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    min-height: calc(100vh - var(--top-nav-height) - var(--bottom-nav-height));
    padding: 20px 16px;
    padding-bottom: 30px;
}

.container-fluid {
    max-width: 100%;
    margin: 0 auto;
}

/* ==================== CARDS ==================== */
.card {
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-lg);
    padding: 20px;
    margin-bottom: 20px;
    transition: all var(--transition-base);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-gradient {
    background: linear-gradient(135deg, var(--gradient-primary-start), var(--gradient-primary-end));
    color: white;
}

.card-gradient-secondary {
    background: linear-gradient(135deg, var(--gradient-secondary-start), var(--gradient-secondary-end));
    color: white;
}

/* Stat Cards */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

/* ==================== BOTTOM NAVIGATION ==================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: white;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    z-index: 1000;
    border-top: 1px solid var(--gray-200);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--gray-500);
    transition: all var(--transition-fast);
    padding: 8px;
    border-radius: 12px;
    margin: 0 4px;
    position: relative;
}

.nav-item i {
    font-size: 24px;
    margin-bottom: 4px;
    transition: all var(--transition-base);
}

.nav-item span {
    font-size: 11px;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active i {
    transform: translateY(-3px);
}

.nav-item::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, var(--gradient-primary-start), var(--gradient-primary-end));
    border-radius: 0 0 4px 4px;
    transition: transform var(--transition-base);
}

.nav-item.active::before {
    transform: translateX(-50%) scaleX(1);
}

.nav-badge {
    position: absolute;
    top: 0;
    right: 20%;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--btn-radius);
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gradient-primary-start), var(--gradient-primary-end));
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--gradient-secondary-start), var(--gradient-secondary-end));
    color: white;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.4);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-light {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 20px);
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-primary-start), var(--gradient-primary-end));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
    cursor: pointer;
    transition: all var(--transition-base);
    z-index: 900;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.6);
}

/* ==================== TABLES ==================== */
.table-container {
    background: white;
    border-radius: var(--card-radius);
    overflow-x: auto;
    /* Enable horizontal scroll */
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
    box-shadow: var(--shadow-md);
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    /* Minimum width to ensure readability */
}

.table thead {
    background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
}

.table th {
    padding: 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-700);
    text-align: left;
}

.table td {
    padding: 16px;
    color: var(--gray-800);
    border-bottom: 1px solid var(--gray-200);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--gray-100);
}

/* ==================== BADGES ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-700);
}

.form-control,
.form-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--btn-radius);
    border: 2px solid var(--gray-200);
    font-size: 14px;
    transition: all var(--transition-fast);
    background: white;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ==================== MOBILE CARD LAYOUT ==================== */
@media (max-width: 768px) {
    .mobile-card-item {
        background: white;
        border-radius: var(--card-radius);
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: var(--shadow-md);
        transition: all var(--transition-base);
    }

    .mobile-card-item:active {
        transform: scale(0.98);
    }

    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
    }

    .mobile-card-title {
        font-weight: 700;
        font-size: 16px;
        color: var(--gray-800);
    }

    .mobile-card-body {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        font-size: 14px;
    }

    .mobile-card-label {
        color: var(--gray-500);
        font-weight: 500;
    }

    .mobile-card-value {
        color: var(--gray-800);
        font-weight: 600;
    }

    .mobile-card-actions {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--gray-200);
    }
}

/* ==================== UTILITIES ==================== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.text-muted {
    color: var(--gray-500);
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--gradient-primary-start), var(--gradient-primary-end));
}

.bg-gradient-secondary {
    background: linear-gradient(135deg, var(--gradient-secondary-start), var(--gradient-secondary-end));
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.p-1 {
    padding: 8px;
}

.p-2 {
    padding: 16px;
}

.p-3 {
    padding: 24px;
}

.d-none {
    display: none !important;
}

.d-flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.gap-1 {
    gap: 8px;
}

.gap-2 {
    gap: 16px;
}

.gap-3 {
    gap: 24px;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 768px) {
    body {
        font-size: 16px;
    }

    .container-fluid {
        max-width: 1200px;
    }

    .main-content {
        padding: 32px 24px;
    }

    .stat-value {
        font-size: 32px;
    }

    /* Hide mobile cards, show tables on desktop */
    .mobile-card-item {
        display: none;
    }
}

@media (min-width: 1024px) {
    .bottom-nav {
        display: none;
    }

    body {
        padding-bottom: 0;
    }

    .main-content {
        padding: 40px 32px;
    }
}