/* ==========================================
   ADMIN DASHBOARD STYLES
   ========================================== */

.admin-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    margin: 0;
    padding: 0;
}

/* ==========================================
   LOGIN SCREEN
   ========================================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 20px;
}

.login-box {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 191, 255, 0.2);
    border-radius: 16px;
    padding: 40px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: #00bfff;
    margin: 0 0 10px 0;
    font-size: 2rem;
}

.login-header p {
    color: #94a3b8;
    margin: 0;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    color: #cbd5e1;
    font-weight: 500;
}

.login-form input {
    width: 100%;
    padding: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(0, 191, 255, 0.2);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 14px;
    transition: all 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: #00bfff;
    box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.1);
}

.login-footer {
    text-align: center;
    margin-top: 20px;
}

.login-footer a {
    color: #00bfff;
    text-decoration: none;
}

.error-message {
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #fca5a5;
    margin-top: 15px;
    font-size: 14px;
}

.magic-link-info {
    color: #94a3b8;
    font-size: 14px;
    margin: 15px 0;
    text-align: center;
}

.login-message {
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 14px;
    text-align: center;
}

.login-message.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.login-message.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.login-message.info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, #00bfff 0%, #0088cc 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 191, 255, 0.4);
}

.btn-secondary {
    background: rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.2);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-success {
    background: rgba(34, 197, 94, 0.1);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.btn-success:hover {
    background: rgba(34, 197, 94, 0.2);
}

.btn-block {
    width: 100%;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* ==========================================
   ADMIN NAVIGATION
   ========================================== */

.admin-nav {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 191, 255, 0.2);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-nav-brand h2 {
    margin: 0;
    color: #00bfff;
    font-size: 1.5rem;
}

.admin-nav-user {
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-nav-user span {
    color: #cbd5e1;
}

/* ==========================================
   ADMIN LAYOUT
   ========================================== */

.admin-layout {
    display: flex;
    min-height: calc(100vh - 70px);
}

.admin-sidebar {
    width: 250px;
    background: rgba(30, 41, 59, 0.5);
    border-right: 1px solid rgba(0, 191, 255, 0.1);
    padding: 20px 0;
}

.admin-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.admin-menu li {
    margin: 0;
}

.admin-menu a {
    display: block;
    padding: 15px 25px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.admin-menu a:hover,
.admin-menu a.active {
    background: rgba(0, 191, 255, 0.1);
    border-left-color: #00bfff;
    color: #00bfff;
}

.admin-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

/* ==========================================
   ADMIN SECTIONS
   ========================================== */

.admin-section h2 {
    color: #00bfff;
    margin-top: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.section-header h2 {
    margin: 0;
}

/* ==========================================
   STATS GRID
   ========================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(0, 191, 255, 0.2);
    border-radius: 12px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 191, 255, 0.2);
    border-color: #00bfff;
}

.stat-icon {
    font-size: 3rem;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #00bfff;
    line-height: 1;
}

.stat-label {
    color: #94a3b8;
    margin-top: 5px;
    font-size: 0.9rem;
}

/* ==========================================
   TABLES
   ========================================== */

.table-container {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(0, 191, 255, 0.1);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px; /* Limit table height for better mobile experience */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Ensure table has minimum width for horizontal scroll */
}

.admin-table th,
.admin-table td {
    white-space: nowrap; /* Prevent text wrapping in cells */
    max-width: 250px; /* Limit cell width */
    overflow: hidden;
    text-overflow: ellipsis; /* Add ... for truncated text */
}

.admin-table thead {
    background: rgba(0, 191, 255, 0.1);
}

.admin-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #00bfff;
    border-bottom: 1px solid rgba(0, 191, 255, 0.2);
}

.admin-table td {
    padding: 15px;
    border-bottom: 1px solid rgba(0, 191, 255, 0.05);
}

.admin-table tbody tr {
    transition: background 0.2s;
}

.admin-table tbody tr:hover {
    background: rgba(0, 191, 255, 0.05);
}

.admin-table .loading {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

/* ==========================================
   SEARCH & FILTERS
   ========================================== */

.search-bar {
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    max-width: 500px;
    padding: 12px 20px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(0, 191, 255, 0.2);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 14px;
}

.search-bar input:focus {
    outline: none;
    border-color: #00bfff;
}

.filters {
    display: flex;
    gap: 15px;
}

.filter-select {
    padding: 10px 15px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(0, 191, 255, 0.2);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 14px;
    cursor: pointer;
}

/* ==========================================
   RECENT ACTIVITY
   ========================================== */

.recent-activity {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(0, 191, 255, 0.1);
    border-radius: 12px;
    padding: 25px;
}

.recent-activity h3 {
    color: #00bfff;
    margin-top: 0;
    margin-bottom: 20px;
}

.activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.activity-item {
    padding: 15px;
    border-bottom: 1px solid rgba(0, 191, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 15px;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    font-size: 1.5rem;
}

.activity-content {
    flex: 1;
}

.activity-title {
    color: #e2e8f0;
    margin-bottom: 5px;
}

.activity-time {
    color: #94a3b8;
    font-size: 0.85rem;
}

/* ==========================================
   MODAL
   ========================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(0, 191, 255, 0.2);
    border-radius: 16px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #cbd5e1;
    cursor: pointer;
    transition: color 0.3s;
}

.modal-close:hover {
    color: #00bfff;
}

#modal-title {
    color: #00bfff;
    margin-top: 0;
}

/* ==========================================
   BADGES
   ========================================== */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-warning {
    background: rgba(251, 191, 36, 0.2);
    color: #fde047;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-info {
    background: rgba(0, 191, 255, 0.2);
    color: #7dd3fc;
    border: 1px solid rgba(0, 191, 255, 0.3);
}

/* ==========================================
   SIDEBAR TOGGLE BUTTON
   ========================================== */

.sidebar-toggle {
    display: none; /* Hidden on desktop */
    background: linear-gradient(135deg, #00bfff 0%, #0097a7 100%);
    border: 2px solid #00bfff;
    color: white;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    z-index: 101;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 191, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-toggle .menu-text {
    display: inline-block;
}

.sidebar-toggle .menu-icon {
    display: inline-block;
    font-size: 12px;
    transition: transform 0.3s ease;
}

.sidebar-toggle:hover {
    background: linear-gradient(135deg, #00d4ff 0%, #00b8c5 100%);
    box-shadow: 0 4px 12px rgba(0, 191, 255, 0.4);
    transform: translateY(-1px);
}

.sidebar-toggle:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 191, 255, 0.3);
}

/* Rotate arrow when menu is open */
.sidebar-toggle.active .menu-icon {
    transform: rotate(180deg);
}

/* ==========================================
   CHECK-IN PROMINENCE STYLES
   ========================================== */

/* Highlight check-in menu item */
.admin-menu a[data-section="checkin"] {
    background: linear-gradient(90deg, rgba(0, 191, 255, 0.15) 0%, transparent 100%);
    border-left-color: #00bfff;
    font-weight: 600;
}

.admin-menu a[data-section="checkin"]:hover {
    background: linear-gradient(90deg, rgba(0, 191, 255, 0.25) 0%, rgba(0, 191, 255, 0.05) 100%);
}

/* Make check-in button more prominent */
.checkin-btn {
    background: linear-gradient(135deg, #00bfff 0%, #0088cc 100%) !important;
    border: 2px solid #00bfff !important;
    box-shadow: 0 4px 15px rgba(0, 191, 255, 0.3);
}

.checkin-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 191, 255, 0.4);
}

/* ==========================================
   LOGOUT BUTTON VISIBILITY
   ========================================== */

/* Hide mobile logout by default (show on mobile only) */
.mobile-logout-menu {
    display: none;
}

/* ==========================================
   RESPONSIVE - MOBILE
   ========================================== */

@media (max-width: 768px) {
    /* Ensure body accounts for sticky navbars */
    body.admin-body {
        padding-top: 100px; /* Space for main navbar */
    }

    /* Show MENU button on mobile */
    .sidebar-toggle {
        display: flex !important;
        min-width: 90px;
        min-height: 44px;
        padding: 12px 20px;
        font-size: 15px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        position: relative;
        z-index: 1000; /* Above everything else */
        pointer-events: auto; /* Ensure it's clickable */
        cursor: pointer;
    }

    .sidebar-toggle:active {
        transform: scale(0.97);
    }

    /* Admin navigation adjustments - KEEP IT VISIBLE */
    .admin-nav {
        padding: 12px 15px;
        flex-wrap: nowrap;
        gap: 12px;
        position: fixed !important; /* Fixed instead of sticky */
        top: 100px !important; /* Position below main navbar - increased for foldable devices */
        left: 0;
        right: 0;
        width: 100%;
        z-index: 999 !important; /* Below main navbar but above content */
        background: rgba(30, 41, 59, 0.98) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    .admin-nav-brand {
        flex: 1;
    }

    .admin-nav-brand h2 {
        font-size: 1.1rem;
    }

    /* Hide the entire user area on mobile (logout is in sidebar) */
    .admin-nav-user {
        display: none !important;
    }

    /* Show mobile logout in sidebar */
    .mobile-logout-menu {
        display: block !important;
    }

    /* Mobile dropdown menu - appears below BOTH navbars */
    .admin-layout {
        position: relative;
        margin-top: 0; /* Remove any top margin */
    }

    .admin-sidebar {
        position: fixed;
        top: 160px; /* Below main navbar (100px) + admin nav (60px) */
        left: 0;
        right: 0;
        width: 100%;
        max-height: 0;
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(20px);
        border-bottom: 2px solid rgba(0, 191, 255, 0.3);
        z-index: 998; /* Below admin-nav */
        transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
        padding: 0;
        overflow: hidden;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
        opacity: 0;
    }

    .admin-sidebar.active {
        max-height: calc(100vh - 160px); /* Account for both navbars */
        padding: 20px 0;
        overflow-y: auto;
        opacity: 1;
    }

    /* No overlay needed for dropdown style */
    .admin-layout.sidebar-active::before {
        display: none;
    }

    /* Make menu items more touch-friendly on mobile */
    .admin-menu a {
        padding: 16px 24px;
        font-size: 1rem;
        min-height: 50px;
        display: flex;
        align-items: center;
    }

    .admin-menu a[data-section="checkin"] {
        background: linear-gradient(90deg, rgba(0, 191, 255, 0.2) 0%, rgba(0, 191, 255, 0.05) 100%);
        border-left-width: 4px;
    }

    /* Admin content - add top padding for fixed navbars */
    .admin-content {
        padding: 20px 15px;
        padding-top: 90px; /* Space for fixed admin-nav */
        width: 100%;
        margin-top: 0;
    }

    /* Section headers */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    /* Stats grid - 2 columns on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-icon {
        font-size: 1.5rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    /* Tables */
    .table-container {
        overflow-x: auto;
        overflow-y: auto;
        max-height: 400px; /* Smaller height on mobile */
        -webkit-overflow-scrolling: touch;
    }

    .admin-table {
        font-size: 0.8rem;
        min-width: 500px; /* Reduced min-width for mobile */
    }

    .admin-table th,
    .admin-table td {
        padding: 8px 6px;
        white-space: nowrap;
        max-width: 150px; /* Smaller max-width on mobile */
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Make action buttons smaller on mobile */
    .admin-table .btn-small {
        padding: 6px 10px;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Filters */
    .filters {
        flex-direction: column;
        gap: 10px;
    }

    .filter-select,
    .search-bar input {
        width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .action-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .action-buttons .btn {
        width: 100%;
    }

    /* Forms */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ==========================================
   RESPONSIVE - TABLET
   ========================================== */

@media (min-width: 769px) and (max-width: 1024px) {
    .admin-sidebar {
        width: 220px;
    }

    .admin-content {
        padding: 25px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
