/* components.css — shared component styles
   Used by: 16+ templates (login, 404, 500, inventory_query, etc.)
   Extended: Phase 3 (QC and Gantt template consolidation) */

/* ==================== CSS Variables ==================== */
:root {
    --primary: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    --bg: #f3f4f6;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* ==================== Base Reset ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ==================== Layout ==================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ==================== Sidebar ==================== */
.sidebar {
    width: 280px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 15px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    margin: 0 0 12px 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.sidebar-search {
    padding: 0 15px 10px 15px;
}

.sidebar-search input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: #f8fafc;
    transition: all 0.2s;
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sidebar-search input::placeholder {
    color: #94a3b8;
}

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

.sidebar-footer .btn {
    width: 100%;
    justify-content: center;
}

.sidebar-empty {
    padding: 30px 15px;
    text-align: center;
    color: #94a3b8;
}

.sidebar-empty-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
}

.sidebar-overlay.show {
    display: block;
}

/* ==================== Main Content ==================== */
.main-content {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content.expanded {
    margin-left: 0;
}

/* ==================== Buttons ==================== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: #6b7280; color: white; }
.btn-secondary:hover { background: #4b5563; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-info { background: #3b82f6; color: white; }
.btn-info:hover { background: #2563eb; }
.btn-warning { background: #f59e0b; color: white; }
.btn-warning:hover { background: #d97706; }

/* ==================== Cards ==================== */
.card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* ==================== Modals ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    color: #6b7280;
}

.modal-close:hover {
    background: #e5e7eb;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ==================== Status Badges ==================== */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending { background: var(--danger); color: white; }
.status-fixed { background: var(--success); color: white; }
.status-verified { background: #dbeafe; color: #1e40af; }
.status-special { background: var(--warning); color: white; }
.status-refused { background: var(--purple); color: white; }
.status-deferred { background: #17a2b8; color: white; }

/* ==================== Tables ==================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
}

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

/* ==================== Lightbox ==================== */
.lightbox,
.image-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.lightbox.show,
.image-lightbox.show {
    display: flex;
}

.lightbox img,
.image-lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close,
.image-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

/* ==================== Form Inputs ==================== */
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

/* ==================== Brand Groups (Collapsible) ==================== */
.brand-group {
    margin-bottom: 6px;
}

.brand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f1f5f9;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.brand-header:hover {
    background: #e2e8f0;
}

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

.brand-name {
    font-weight: bold;
    font-size: 14px;
    color: var(--text);
}

.brand-count {
    background: #cbd5e1;
    color: #475569;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.brand-toggle {
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.2s;
}

.brand-toggle.collapsed {
    transform: rotate(-90deg);
}

.brand-reports {
    padding: 4px 0 4px 12px;
}

.brand-reports.hidden {
    display: none;
}

/* ==================== Report Items ==================== */
.report-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.report-item {
    padding: 12px;
    margin: 4px 0;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.report-item:hover {
    border-color: #cbd5e1;
}

.report-item.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.report-item-title {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 4px;
}

.report-item.active .report-item-title {
    color: white;
}

.report-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.report-item.active .report-item-meta {
    color: #bfdbfe;
}

/* ==================== Photo Grid ==================== */
.photo-grid {
    display: flex;
    gap: 10px;
}

.photo-box {
    text-align: center;
}

.photo-box img {
    max-width: 100px;
    max-height: 80px;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid #ddd;
}

.photo-box img:hover {
    transform: scale(1.05);
}

.photo-box span {
    font-size: 9px;
    color: var(--text-muted);
}

/* ==================== Empty State ==================== */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 56px;
    margin-bottom: 15px;
}

.empty-state-text {
    font-size: 15px;
    margin-bottom: 8px;
}

.empty-state-hint {
    font-size: 12px;
    color: #94a3b8;
}

/* ==================== Toast Notifications ==================== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 14px;
    z-index: 9999;
    animation: toastIn 0.3s ease;
}

.toast.error {
    background: var(--danger);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ==================== Loading Overlay ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==================== Spinner ==================== */
.spinner-border {
    width: 2rem;
    height: 2rem;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
    display: inline-block;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== Text Utilities ==================== */
.text-center { text-align: center; }
.text-primary { color: #3b82f6; }
.text-danger { color: #ef4444; }
.text-success { color: #10b981; }
.text-muted { color: var(--text-muted); }

/* ==================== Menu Toggle ==================== */
.menu-toggle {
    display: flex;
    width: 40px;
    height: 40px;
    border: none;
    background: #e2e8f0;
    border-radius: 8px;
    color: #1f2937;
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.menu-toggle:hover {
    background: #cbd5e1;
}

/* ==================== Print Styles ==================== */
@media print {
    .sidebar,
    .no-print,
    .header-actions,
    .top-toolbar {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .container {
        box-shadow: none;
        padding: 0;
    }
}
