/* ============================================================
   AfriHive - Base Styles
   ============================================================ */

:root {
    --color-primary: #f5a623;
    --color-primary-dark: #d4891a;
    --color-primary-light: #fcebd0;
    --color-bg: #f7f8fa;
    --color-surface: #ffffff;
    --color-text: #2d3436;
    --color-text-light: #636e72;
    --color-border: #dfe6e9;
    --color-success: #00b894;
    --color-danger: #d63031;
    --color-warning: #fdcb6e;
    --color-info: #0984e3;
    --radius: 6px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --sidebar-width: 220px;
    --header-height: 56px;
    --transition: 0.2s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

/* ============================================================
   Login Page
   ============================================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5a623 0%, #d4891a 100%);
}

.login-container {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

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

.login-header h1 {
    font-size: 28px;
    color: var(--color-primary-dark);
    margin-bottom: 4px;
}

.login-header p {
    color: var(--color-text-light);
    font-size: 14px;
}

/* ============================================================
   Forms
   ============================================================ */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
    background: var(--color-surface);
    color: var(--color-text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.error-message {
    color: var(--color-danger);
    font-size: 13px;
    margin-bottom: 12px;
    padding: 8px;
    background: #ffeaea;
    border-radius: var(--radius);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    gap: 6px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn-outline {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-bg);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 20px;
    line-height: 1;
    color: var(--color-text);
}

/* ============================================================
   App Shell Layout
   ============================================================ */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 20px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-title {
    font-size: 18px;
    color: var(--color-primary-dark);
}

.current-user {
    font-size: 13px;
    color: var(--color-text-light);
}

.menu-toggle {
    display: none;
}

.hamburger {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-text);
    position: relative;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: var(--color-text);
    left: 0;
}

.hamburger::before { top: -6px; }
.hamburger::after { top: 6px; }

.app-body {
    display: flex;
    flex: 1;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 16px 0;
    flex-shrink: 0;
    overflow-y: auto;
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
}

.nav-list {
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--color-text-light);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition);
    gap: 10px;
    font-size: 14px;
}

.nav-link:hover {
    color: var(--color-text);
    background: var(--color-bg);
}

.nav-link.active {
    color: var(--color-primary-dark);
    background: var(--color-primary-light);
    border-right: 3px solid var(--color-primary);
}

.nav-icon {
    font-size: 10px;
    width: 20px;
    text-align: center;
}

.nav-separator {
    height: 1px;
    background: var(--color-border);
    margin: 8px 16px;
}

/* ============================================================
   Main Content
   ============================================================ */

.main-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.page-content {
    display: none;
}

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

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

.page-header h2 {
    font-size: 20px;
}

.placeholder-text {
    color: var(--color-text-light);
    font-style: italic;
    padding: 40px 0;
    text-align: center;
}

/* ============================================================
   Cards
   ============================================================ */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--color-primary-dark);
}

.stat-label {
    font-size: 13px;
    color: var(--color-text-light);
    margin-top: 4px;
}

/* ============================================================
   Data Tables
   ============================================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    background: var(--color-bg);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-light);
}

.data-table tbody tr:hover {
    background: #fafafa;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active { background: #e6f9f0; color: var(--color-success); }
.status-inactive { background: #ffeaea; color: var(--color-danger); }

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 16px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
    font-size: 16px;
}

.modal-close {
    font-size: 24px;
    color: var(--color-text-light);
}

.modal-body {
    padding: 20px;
}

.modal-body .form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ============================================================
   Report Tabs
   ============================================================ */

.report-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 20px;
    overflow-x: auto;
}

.btn-tab {
    padding: 10px 18px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    border-radius: 0;
    font-family: inherit;
}

.btn-tab:hover {
    color: var(--color-text);
    background: var(--color-primary-light);
}

.btn-tab.active {
    color: var(--color-primary-dark);
    border-bottom-color: var(--color-primary);
}

.report-content {
    min-height: 200px;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 90;
        transform: translateX(-100%);
        transition: transform var(--transition);
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        padding: 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .insp-tabs {
        flex-wrap: wrap;
    }

    .insp-tab {
        font-size: 11px;
        padding: 4px 8px;
    }

    .modal {
        max-width: 95vw;
    }
}

/* ============================================================
   Inspection Form
   ============================================================ */

.insp-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 16px;
    overflow-x: auto;
}

.insp-tab {
    padding: 8px 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    font-family: inherit;
}

.insp-tab:hover {
    color: var(--color-text);
}

.insp-tab.active {
    color: var(--color-primary-dark);
    border-bottom-color: var(--color-primary);
}

.insp-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
}

#insp-tab-indicator {
    font-size: 13px;
    color: var(--color-text-light);
}

.score-group {
    display: flex;
    gap: 12px;
}

.score-label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.cb-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
}

#insp-form-container .modal {
    max-width: 600px;
}

/* ---- QR Codes Page ---- */
.qr-codes-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.qr-template-card,
.qr-list-card {
    padding: 20px;
}

.qr-template-info {
    margin-top: 8px;
    font-size: 13px;
    color: var(--color-text-light);
}

.qr-assign-area {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.text-muted {
    color: var(--color-text-light);
}

.text-danger {
    color: var(--color-danger);
}

/* ---- Photo Previews ---- */
.photo-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.photo-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.photo-thumb-wrap {
    position: relative;
    display: inline-block;
}

.photo-thumb-wrap .photo-del {
    position: absolute;
    top: 2px;
    right: 2px;
    padding: 0 4px;
    font-size: 11px;
    line-height: 18px;
    min-width: auto;
}

@media (max-width: 768px) {
    .qr-codes-layout {
        grid-template-columns: 1fr;
    }
}
