/* assets/css/style.css */

/* =========================================
   1. VARIABLES & THEME SETUP
   ========================================= */
:root {
    /* Dimensions & Spacing */
    --max-width: 1200px;
    --sidebar-width: clamp(300px, 30vw, 400px); /* Fluid width */
    --nav-height: 70px;
    --border-radius: 10px; /* Slightly softer corners */
    
    /* Spacing Scale */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    
    /* Light Mode Colors */
    --primary: #C5B358;        /* Old Gold */
    --primary-hover: #b09b3c;
    --accent-blue: #0056b3;    /* For links/info */
    
    --bg-body: #f0f2f5;        /* Slightly darker white for contrast */
    --bg-surface: #ffffff;     /* Cards */
    --bg-input: #ffffff;
    
    --text-main: #2c3e50;
    --text-muted: #6c757d;
    
    --border: #dee2e6;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 16px rgba(0,0,0,0.08);

    /* State Colors */
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
}

/* Dark Mode Overrides */
html.dark-mode {
    --bg-body: #121212;
    --bg-surface: #1e1e1e;
    --bg-input: #2d2d2d;
    
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    
    --border: #444444;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 16px rgba(0,0,0,0.5);
}

/* =========================================
   2. GLOBAL RESET & BASE STYLES
   ========================================= */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape on iPhone */
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a { color: inherit; text-decoration: none; transition: color 0.2s; }
img { max-width: 100%; height: auto; display: block; }

/* =========================================
   3. NAVIGATION BAR (Mobile Optimized)
   ========================================= */
.navbar {
    background: #000000;
    border-bottom: 4px solid var(--primary);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allows wrapping on very small screens */
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-weight: 800;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.brand span { color: var(--primary); }

.logo-img {
    height: 40px;
    width: auto;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Theme Toggle */
.theme-toggle {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

/* =========================================
   4. LAYOUT GRID
   ========================================= */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-md) var(--space-sm);
    flex: 1;
}

/* The Main Layout: Sidebar (Left) + Content (Right) */
.grid-main {
    display: grid;
    /* Uses minmax so sidebar never gets too small or too big */
    grid-template-columns: minmax(280px, var(--sidebar-width)) 1fr;
    gap: var(--space-lg);
    align-items: start;
}

/* Helper for Admin Dashboard to ensure proper flexing */
.content-area {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-width: 0; /* Critical for preventing grid blowouts with tables */
}

/* =========================================
   5. CARDS & SECTIONS
   ========================================= */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Only hover effect on interactive item cards, not forms */
.item-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.card-header {
    background: var(--bg-surface);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    margin: 0;
    color: var(--primary-hover); /* Darker gold for readability */
    font-size: 1.25rem;
    font-weight: 700;
}

/* Dark mode adjustment for header text */
html.dark-mode .card-header h2 {
    color: var(--primary);
}

.card-body {
    padding: var(--space-md);
}

/* =========================================
   6. FORMS & INPUTS
   ========================================= */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

/* Base Input Styles */
.form-input, textarea, select {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 6px;
    font-size: 16px; /* Prevents iOS Zoom */
    transition: all 0.2s ease;
    -webkit-appearance: none; /* Removes default styling on iOS */
}

.form-input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(197, 179, 88, 0.2);
}

.form-input:disabled {
    background-color: rgba(0,0,0,0.05);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Search Bar Specifics */
.search-bar-container {
    margin-bottom: var(--space-md);
}
.search-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: 50px;
    background: var(--bg-surface);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}
.search-input:focus {
    border-color: var(--primary);
    outline: none;
}

/* =========================================
   7. BUTTONS
   ========================================= */
.btn {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    background: var(--primary);
    color: #1a1a1a;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    transition: filter 0.2s, transform 0.1s;
}

.btn:hover {
    filter: brightness(0.9);
}

.btn:active {
    transform: translateY(1px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--primary);
    color: #000;
}

/* =========================================
   8. ITEMS GRID & IMAGES
   ========================================= */
.item-grid {
    display: grid;
    /* Auto-fit: Creates as many columns as fit with min width of 250px */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--space-md);
}

.item-img-wrap {
    height: 200px;
    width: 100%;
    background: #000;
    position: relative;
    overflow: hidden;
}

.item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.item-card:hover .item-img {
    transform: scale(1.05); /* Subtle zoom on hover */
}

.placeholder-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #333;
    color: #666;
    font-weight: bold;
    text-transform: uppercase;
}

.meta-info {
    margin: 10px 0 15px 0;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

/* =========================================
   9. ADMIN TABLES (Responsive)
   ========================================= */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Forces scroll on small screens */
    background: var(--bg-surface);
}

.admin-table th {
    background: rgba(0,0,0,0.03);
    text-align: left;
    padding: 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.admin-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

/* =========================================
   10. MODALS
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px); /* Modern blur effect */
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-box {
    background: var(--bg-surface);
    width: 100%;
    max-width: 500px;
    border-radius: var(--border-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}

/* =========================================
   11. MEDIA QUERIES (The "All Platforms" Logic)
   ========================================= */

/* Tablet & Smaller Desktop (Max 900px) */
@media (max-width: 900px) {
    .grid-main {
        grid-template-columns: 1fr; /* Stack sidebar on top of content */
        gap: var(--space-md);
    }

    /* Make the sidebar grid (on Student Home) 2 columns if possible */
    .card-body form {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    /* Make form elements span full width inside the grid */
    .form-group.full-width, 
    .card-body form .divider,
    .card-body form button {
        grid-column: 1 / -1;
    }
}

/* Mobile Devices (Max 600px) */
@media (max-width: 600px) {
    /* Reset the grid inside forms to single column for mobile */
    .card-body form {
        display: block;
    }

    .nav-container {
        flex-direction: column;
        padding-bottom: 10px;
    }

    .brand {
        margin-bottom: 10px;
    }
    
    .card-header, .card-body {
        padding: 1.25rem;
    }
    
    /* Enhance buttons for touch */
    .btn {
        padding: 16px; 
    }
}

/* =========================================
   12. UTILITIES
   ========================================= */
.hidden { display: none !important; }

.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

.status-msg {
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    display: none;
}
.status-loading { background: #e2e3e5; color: #383d41; }
.status-success { background: #d4edda; color: #155724; }
.status-error { background: #f8d7da; color: #721c24; }

/* AI Tag Styles */
.ai-box {
    margin-top: 10px;
    padding: 10px;
    background: rgba(197, 179, 88, 0.1);
    border: 1px solid var(--primary);
    border-radius: 6px;
    font-size: 0.85rem;
}

/* Footer Styles */
footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding: 2rem;
    margin-top: auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer-links button {
    background: none;
    border: none;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    padding: 0;
}