/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 120px 0 2rem;
    /* Increased top padding to prevent clipping */
    background-color: var(--bg-primary);
    /* Keep login page as is */
}

/* Force white background for main admin area */
body {
    background-color: #ffffff;
}

.data-table th,
.data-table td {
    padding: 1.25rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    /* Force horizontal scroll if needed */
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.login-card {
    background-color: white;
    padding: 3rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    text-align: center;
}

.login-header {
    margin-bottom: 2.5rem;
}

.login-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 1rem;
    background-color: #fff;
    transition: var(--transition);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    outline: none;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    /* Rounded buttons */
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: #e0e0e0;
    color: var(--text-primary);
    margin-right: 1rem;
}

.btn-secondary:hover {
    background-color: #cfcfcf;
}

.login-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

.back-link {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.back-link:hover {
    color: var(--accent);
}

.error-message {
    margin-top: 1rem;
    color: #d32f2f;
    font-size: 0.9rem;
    background-color: rgba(211, 47, 47, 0.1);
    padding: 0.5rem;
    border-radius: 4px;
}

/* Admin Styling */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background-color: #111;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
}

.admin-sidebar-header {
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background-color: #111;
    /* Ensure opaque */
    flex-shrink: 0;
}

.logo-small {
    background-color: white;
    color: black;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
}

.logo-text {
    font-weight: 600;
    letter-spacing: 0.5px;
    display: block;
    /* Ensure visibility */
}

/* Admin Sidebar Nav */
.admin-sidebar-nav {
    padding: 2rem 1rem;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    /* Flexbox for column layout */
    flex-direction: column;
    gap: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: var(--transition);
    border-radius: 6px;
    font-size: 0.95rem;
    width: 100%;
    /* Ensure full width */
}

.nav-link:hover,
.nav-link.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

.admin-sidebar-footer {
    padding: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
    background-color: #1a1a1a;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #1F1F1F;
    /* Charcoal Black */
    padding: 1rem 1.5rem;
    width: 100%;
    color: white !important;
    /* Force White Text */
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.user-details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: white !important;
}

.user-role {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7) !important;
}

.logout-btn {
    color: rgba(255, 255, 255, 0.8);
    transition: var(--transition);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.logout-btn:hover {
    color: white;
}

/* ... existing styles ... */
.logout-btn {
    color: rgba(255, 255, 255, 0.5);
    transition: var(--transition);
    background: none;
    border: none;
    cursor: pointer;
}

.logout-btn:hover {
    color: #ff4757;
}

.admin-main {
    flex-grow: 1;
    margin-left: 260px;
    background-color: #ffffff;
    padding: 3rem;
    min-width: 0;
    /* Critical for shrink */
    max-width: 100%;
    /* Ensure it doesn't overflow parent */
    width: 0;
    /* Flexbox trick: forces it to respect flex-grow and not content width */
}

/* ... existing styles ... */

.page-header {
    margin-bottom: 2.5rem;
    overflow-wrap: break-word;
    /* Prevent header overflow */
}

/* ... existing styles ... */

/* Table */
.table-card {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    width: 100%;
    /* Ensure it doesnt exceed parent */
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    /* Ensure block context */
}

.data-table {
    width: 100%;
    min-width: 1200px;
    /* Increased to guarantee scroll */
    border-collapse: separate;
    border-spacing: 0;
}

/* Tab Logic */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

.admin-overlay.active {
    display: block;
}

.admin-menu-toggle.hidden,
#admin-menu-toggle.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Hide hamburger on desktop */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.stat-card {
    background-color: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.purple {
    background-color: rgba(156, 39, 176, 0.1);
    color: #9c27b0;
}

.blue {
    background-color: rgba(33, 150, 243, 0.1);
    color: #2196f3;
}

.green {
    background-color: rgba(76, 175, 80, 0.1);
    color: #4caf50;
}

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-heading);
}

/* Forms */
.form-card {
    background-color: white;
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    max-width: 800px;
}

.form-row {
    display: flex;
    gap: 1.5rem;
}

.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background-color: #fafafa;
}

.file-upload-area:hover {
    border-color: var(--accent);
    background-color: #f0f0f0;
}

.file-upload-area.dragover {
    border-color: var(--accent);
    background-color: rgba(0, 0, 0, 0.05);
}

.upload-content i {
    font-size: 3rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.browser-btn {
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
}

.upload-hint {
    font-size: 0.8rem;
    color: #999;
    margin-top: 0.5rem;
}

.preview-area {
    margin-top: 1rem;
    position: relative;
    display: inline-block;
}

#image-preview {
    max-height: 200px;
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.remove-image {
    position: absolute;
    top: -10px;
    right: -10px;
    background-color: red;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #eee;
}

/* Table */
.table-card {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    /* overflow: hidden; Removed to allow responsive table scroll */
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 1000px;
    /* Force scroll on smaller screens/windows */
    border-collapse: separate;
    border-spacing: 0;
}



.data-table th {
    background-color: #fafafa;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.data-table td {
    font-size: 0.95rem;
    vertical-align: middle;
}

.data-table img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
}

.action-btn {
    padding: 6px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: var(--transition);
    margin: 0 5px;
}

.action-btn:hover {
    color: var(--accent);
}

.action-btn.delete:hover {
    color: #d32f2f;
}

/* Modal */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-backdrop.active {
    display: flex;
}

.modal-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-title {
    font-size: 1.5rem;
    font-family: var(--font-heading);
    color: var(--text-heading);
    margin-bottom: 1.5rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.narrow {
    max-width: 600px;
    padding: 0;
}

.narrow form {
    padding: 2rem;
}

.narrow .modal-title {
    padding: 2rem 2rem 0;
}

.narrow .modal-close {
    top: 2rem;
    right: 2rem;
}

/* Type Selector */
.type-selector {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

.radio-label input[type="radio"] {
    width: auto;
    margin: 0;
}

/* Toast for Admin */
#admin-toast {
    background-color: #333;
    bottom: 20px;
    top: auto;
    transform: translateY(100px) translateX(-50%);
}

#admin-toast.show {
    transform: translateY(0) translateX(-50%);
}

/* ------------------------------------------------------------------ */
/* Mobile Responsiveness for Admin Dashboard */
/* ------------------------------------------------------------------ */
@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        width: 280px;
        /* Slightly wider for better touch targets if needed, or keep 260 */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }

    .admin-sidebar.active {
        transform: translateX(0);
    }

    .admin-main {
        margin-left: 0;
        padding: 1.5rem;
        width: 100%;
    }

    /* Fix Header size on mobile */
    .page-header h1 {
        font-size: 1.5rem;
    }

    /* Stats Grid 1 col */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Form Card padding */
    .form-card {
        padding: 1.5rem;
    }

    /* Table scroll handled by table-responsive globally */
    .table-card {
        /* overflow-x: auto;  Redundant */
    }

    .data-table {
        min-width: 600px;
        /* Force scroll */
    }

    /* Hide Hamburger when Sidebar is Active (Nuclear Option) */
    body.sidebar-open #admin-menu-toggle {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Adjust Overlay z-index */
    .admin-overlay {
        z-index: 999;
        /* Below sidebar, above content */
        background-color: rgba(0, 0, 0, 0.5);
        /* Dimming */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: none;
        /* Hidden by default */
    }

    .admin-overlay.active {
        display: block;
        /* Show when active */
    }

    /* Admin Menu Toggle Styling (Left, Square, Black Border) */
    .admin-menu-toggle,
    #admin-menu-toggle {
        display: flex !important;
        position: fixed;
        top: 15px !important;
        left: 20px;
        z-index: 10001 !important;
        background: #000 !important;
        color: #fff !important;
        border: 2px solid #fff;
        border-radius: 8px;
        width: 45px;
        height: 45px;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    }
}