/* style.css - Fix Layout & Modals */
:root {
    --bg-base: #0b0f19;
    --bg-surface: #131c2f;
    --bg-surface-hover: #1e293b;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.2);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.2);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.2);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.2);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --font-main: 'Inter', sans-serif;
}

[data-theme='light'] {
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --primary: #4f46e5;
}

[data-theme='midnight'] {
    --bg-base: #020617;
    --bg-surface: #0f172a;
    --primary: #38bdf8;
    --border: rgba(56, 189, 248, 0.15);
}

[data-theme='matrix'] {
    --bg-base: #000000;
    --bg-surface: #050505;
    --primary: #00ff41;
    --text-main: #00ff41;
    --text-muted: #008f11;
    --border: #003b00;
    --radius-lg: 0px;
    --radius-md: 0px;
    --radius-sm: 0px;
}

.hidden { display: none !important; }

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-main); background-color: var(--bg-base); color: var(--text-main); height: 100vh; width: 100vw; display: flex; overflow: hidden; }

.app-container { display: flex; width: 100%; height: 100%; overflow: hidden; }

/* Sidebar */
.sidebar { width: 260px; min-width: 260px; background-color: var(--bg-surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1.5rem; flex-shrink: 0; }
.logo-container { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
.logo-icon { width: 40px; height: 40px; background: linear-gradient(135deg, var(--primary), #8b5cf6); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; color: white; font-size: 1.25rem; }
.logo-text { font-size: 1.5rem; font-weight: 800; color: var(--text-main); }

.nav-item { display: flex; align-items: center; gap: 1rem; padding: 0.8rem 1rem; border-radius: var(--radius-sm); color: var(--text-muted); text-decoration: none; font-weight: 600; margin-bottom: 4px; transition: 0.2s; }
.nav-item:hover { background: var(--bg-surface-hover); color: var(--text-main); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.top-header { height: 72px; min-height: 72px; padding: 0 2rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--bg-surface); }

.search-container { position: relative; width: 100%; max-width: 450px; display: flex; align-items: center; }
.search-icon { position: absolute; left: 1rem; color: var(--text-muted); }
#global-search { width: 100%; padding: 0.65rem 3rem 0.65rem 2.5rem; background: var(--bg-base); border: 1px solid var(--border); border-radius: 99px; color: var(--text-main); outline: none; }
.btn-pdf-search { position: absolute; right: 8px; background: var(--primary); border: none; color: white; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0.8; }

.header-actions { display: flex; gap: 1rem; align-items: center; margin-left: 1rem; }

.content-area { padding: 2rem; flex: 1; overflow-y: auto; width: 100%; }
.view-section { display: none; }
.view-section.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; display: flex; align-items: center; gap: 1rem; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }

/* Table */
.data-container { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; width: 100%; }
.table-responsive { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th { text-align: left; padding: 1rem; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; background: rgba(0,0,0,0.05); }
td { padding: 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

/* Modal Overlay Fix */
.modal-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    background: rgba(0, 0, 0, 0.75); 
    backdrop-filter: blur(5px); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 9999; 
    opacity: 0; 
    pointer-events: none; 
    transition: opacity 0.3s ease; 
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-content { 
    background: var(--bg-surface); 
    width: 95%; 
    max-width: 650px; 
    border-radius: var(--radius-lg); 
    border: 1px solid var(--border); 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden; 
}

.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; max-height: 80vh; overflow-y: auto; }
.modal-footer { padding: 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 1rem; }

/* Modal Form Grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group.full-width { grid-column: span 2; }

label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
input, select, textarea { 
    width: 100%; 
    padding: 0.75rem; 
    background: var(--bg-base); 
    border: 1px solid var(--border); 
    border-radius: var(--radius-sm); 
    color: white; 
    outline: none; 
    transition: 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }

.btn { padding: 0.7rem 1.5rem; border-radius: var(--radius-sm); border: none; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; transition: 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1rem; }
.theme-btn { padding: 1rem; border: 2px solid var(--border); border-radius: var(--radius-md); cursor: pointer; background: var(--bg-base); color: var(--text-main); font-weight: 700; }
.theme-btn.active { border-color: var(--primary); background: var(--primary-light); }

#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 10000; }

.preview-item:hover button { display: block !important; }

.badge { padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 700; }
.badge-funciona { background: var(--success-light); color: var(--success); }
.badge-repuestos { background: var(--danger-light); color: var(--danger); }

.nav-photo-btn:hover { background: var(--primary) !important; scale: 1.1; }

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    background: rgba(255,255,255,0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.drop-zone i { font-size: 2rem; color: var(--primary); }
.drop-zone p { font-weight: 600; font-size: 0.9rem; }
