/* assets/css/style.css */

/* =========================================
   1. VARIABLES & THEME SETUP
   ========================================= */
:root {
    /* Dimensions & Spacing */
    --max-width: 1200px;
    --sidebar-width: clamp(300px, 30vw, 400px);
    --nav-height: 70px;
    --border-radius: 10px;
    
    /* Spacing Scale */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    
    /* Colors */
    --primary: #C5B358;        /* Old Gold */
    --primary-hover: #b09b3c;
    --accent-blue: #0056b3;    
    --bg-body: #f0f2f5;
    --bg-surface: #ffffff;
    --bg-input: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #6c757d;
    --border: #dee2e6;
    
    /* State Colors */
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info-bg: #e8f0fe;
    --info-text: #1a73e8;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 16px rgba(0,0,0,0.08);
}

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);
    --info-bg: #1a2a3a;
    --info-text: #64b5f6;
}

/* =========================================
   2. GLOBAL RESET
   ========================================= */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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
   ========================================= */
.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;
    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; }

/* Utility class replacing inline styles in header */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.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
   ========================================= */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-md) var(--space-sm);
    flex: 1;
}

.grid-main {
    display: grid;
    grid-template-columns: minmax(280px, var(--sidebar-width)) 1fr;
    gap: var(--space-lg);
    align-items: start;
}

/* =========================================
   5. CARDS
   ========================================= */
.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;
}

.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);
    font-size: 1.25rem;
    font-weight: 700;
}
html.dark-mode .card-header h2 { color: var(--primary); }

.card-body { padding: var(--space-md); }

/* =========================================
   6. FORMS
   ========================================= */
.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);
}

.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;
    transition: all 0.2s ease;
    -webkit-appearance: none;
}
.form-input: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-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);
}

/* New: Checkbox & Terms Styling */
.checkbox-wrapper {
    background: var(--bg-body);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}
.checkbox-flex {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.checkbox-input {
    width: 20px;
    height: 20px;
    margin-top: 3px;
    flex-shrink: 0;
}
.terms-label {
    font-size: 0.9rem;
    line-height: 1.4;
    cursor: pointer;
}
.btn-link-terms {
    background: none;
    border: none;
    color: var(--primary-hover);
    text-decoration: underline;
    padding: 0;
    cursor: pointer;
    font-weight: bold;
    font-size: inherit;
}
.divider {
    margin: 20px 0;
    border: 0;
    border-top: 1px solid var(--border);
}

/* =========================================
   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;
}
.btn-nav-home {
    border: none;
    color: white;
    padding: 5px 10px;
}

/* Tiny Action Button */
.btn-xs-action {
    display: inline-block;
    padding: 4px 10px;
    margin-left: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--text-main);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-xs-action:hover {
    background: var(--primary);
    color: #000;
}
.btn-xs-action:disabled {
    border-color: var(--success);
    color: var(--success);
    cursor: default;
    background: transparent;
}

/* Admin Button Variants */
.btn-sm { padding: 6px; font-size: 0.8rem; }
.btn-xs { padding: 5px 10px; font-size: 0.8rem; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-logout { background: var(--danger); color: white; margin-top: 20px; }

/* =========================================
   8. ITEMS & IMAGES
   ========================================= */
.item-grid {
    display: grid;
    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: contain;
    transition: transform 0.5s ease;
}
.item-card:hover .item-img { transform: scale(1.05); }

.placeholder-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #333;
    color: #666;
    font-weight: bold;
    text-transform: uppercase;
}
.img-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
}
.img-thumb-placeholder {
    width: 50px;
    height: 50px;
    background: #eee;
    border-radius: 4px;
}

.meta-info {
    margin: 10px 0 15px 0;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

.ocr-badge {
    background: var(--info-bg);
    color: var(--info-text);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 10px;
    display: inline-block;
}

.preview-area-wrapper { margin-top: 10px; }
.preview-img-file { max-height: 200px; border-radius: 6px; }

/* =========================================
   9. ADMIN & TABLES
   ========================================= */
.admin-nav { display: flex; flex-direction: column; gap: 10px; }

.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;
    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;
}

/* Width Helpers */
.w-10 { width: 10%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-40 { width: 40%; }

.scroll-text { max-height: 80px; overflow-y: auto; font-size: 0.9rem; }
.action-group { display: flex; gap: 8px; }
.flex-1 { flex: 1; }

.content-area {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-width: 0;
}

/* =========================================
   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);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    display: none; /* Default hidden */
}
/* Display block/flex is handled via JS toggling the display property */

.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;
}

.terms-alert {
    background: rgba(220, 53, 69, 0.1);
    border-left: 4px solid #dc3545;
    padding: 15px;
    margin-bottom: 20px;
}

/* =========================================
   11. UTILITIES & STATUS
   ========================================= */
.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-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;
}

/* Security & Alerts */
.card-security {
    border-left: 5px solid var(--danger);
}
.text-danger-header {
    color: var(--danger);
}
.row-danger {
    background-color: rgba(220, 53, 69, 0.05);
}
.alert-link {
    text-decoration: underline;
    font-weight: 700;
    color: inherit;
}
.btn-nav-security {
    border-color: var(--danger);
    color: var(--danger);
}

/* =========================================
   12. FOOTER
   ========================================= */
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;
}
.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    padding: 0;
}
.separator { margin: 0 5px; }

/* =========================================
   13. MEDIA QUERIES
   ========================================= */
@media (max-width: 900px) {
    .grid-main { grid-template-columns: 1fr; gap: var(--space-md); }
    .card-body form { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
    .form-group.full-width, .divider, .card-body form button { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
    .card-body form { display: block; }
    .nav-container { flex-direction: column; padding-bottom: 10px; }
    .brand { margin-bottom: 10px; }
    .card-header, .card-body { padding: 1.25rem; }
    .btn { padding: 16px; }
}