@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --glass: rgba(255, 255, 255, 0.7);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --header-height: 70px;
    /* Use variable for consistency */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    /* Native App Feel */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    width: 100%;
    -webkit-font-smoothing: antialiased;
}

/* Utilities */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: block !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    h3 {
        font-size: 1.1rem !important;
    }

    .container,
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* Hide Scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
html {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

a {
    text-decoration: none;
    color: inherit;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-warning {
    background-color: var(--warning);
    color: white;
}

.btn-warning:hover {
    background-color: #d97706;
    transform: translateY(-1px);
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #059669;
    /* Darker Green */
    transform: translateY(-1px);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
    /* Darker Red */
    transform: translateY(-1px);
}

.btn-outline-warning {
    border: 1px solid var(--warning);
    color: var(--warning);
    background: transparent;
}

.btn-outline-warning:hover {
    background: var(--warning);
    color: white;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.glass-morphism {
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Layout */
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: #1e293b;
    color: white;
    padding: 1.5rem;
    z-index: 1000;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    transition: transform 0.3s ease-in-out;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.main-content {
    margin-left: 260px;
    padding: 2rem;
    min-height: 100vh;
    transition: margin-left 0.3s ease-in-out;
}

.nav-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.2s;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
}

/* Premium Login Page */
.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
    top: -50%;
    left: -50%;
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    outline: none;
    transition: border-color 0.2s;
    font-size: 1rem;
    /* Prevent iOS zoom */
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

@media (max-width: 768px) {
    .btn {
        padding: 0.75rem 1.5rem;
        /* Larger touch target */
        width: 100%;
        /* Full width buttons on mobile usually look better */
        margin-bottom: 0.5rem;
    }

    .btn:last-child {
        margin-bottom: 0;
    }

    /* Fix form grouping spacing */
    .form-group {
        margin-bottom: 1.5rem;
    }

    label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
}

/* Responsive Utilities */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.bottom-nav {
    display: none;
}

/* Dashboard Layout */
.dashboard-bottom-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-bottom: 80px;
        /* Space for bottom nav */
    }

    #sidebarToggle {
        display: inline-flex !important;
    }

    .header-bar {
        padding: 0.75rem 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    .dashboard-bottom-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .card {
        padding: 1rem;
    }

    /* Mobile Tables - Stacked card view for small screens */
    /* Mobile Tables - Card View Transformation */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    /* Hide table headers accessible way */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* Card Style Rows */
    tr {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 1rem;
        background: #fff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    }

    /* Cells as Rows */
    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 0.75rem 1rem !important;
        border-bottom: 1px solid var(--border);
        min-height: 48px;
        font-size: 0.95rem;
    }

    td:last-child {
        border-bottom: 0;
        justify-content: flex-end;
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    /* Label from data-attribute */
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-align: left;
        margin-right: auto;
        padding-right: 1rem;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* Reset min-width from previous fix */
    table {
        min-width: 0 !important;
    }

    .user-info span:not(.badge) {
        display: none;
        /* Hide 'Welcome, Name' on mobile to save space */
    }

    /* Bottom Navigation */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: #ffffff;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 9999;
        justify-content: space-around;
        padding: 0.75rem 0.5rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        border-top: 1px solid var(--border);
    }

    .bottom-nav .nav-item {
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.5rem;
        color: var(--text-muted);
        font-size: 0.75rem;
        margin-bottom: 0;
        background: transparent;
    }

    .bottom-nav .nav-item i {
        font-size: 1.25rem;
        margin-bottom: 2px;
    }

    .bottom-nav .nav-item.active {
        color: var(--primary);
        font-weight: 600;
        background: transparent;
    }

    .bottom-nav .nav-item:hover {
        background: transparent;
        color: var(--primary);
    }
}