/* ═══════════════════════════════════════════════════════════
   FOTO CARNET PRO WEB - Estilos Principales
   Interfaz profesional para fotos de documentos
   ═══════════════════════════════════════════════════════════ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 280px;
    --header-height: 56px;
    --preview-width: 300px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    overflow: hidden;
    height: 100vh;
}

/* ═══════════════ HEADER ═══════════════ */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 100;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title .logo {
    font-size: 24px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-actions button {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.header-actions button:hover {
    background: rgba(255,255,255,0.25);
}

/* ═══════════════ LAYOUT PRINCIPAL ═══════════════ */
.main-container {
    display: flex;
    height: calc(100vh - var(--header-height));
}

/* ═══════════════ PANEL IZQUIERDO ═══════════════ */
.sidebar-left {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-left::-webkit-scrollbar {
    width: 6px;
}

.sidebar-left::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

/* ═══════════════ SLOTS DE FOTO ═══════════════ */
.slots-container {
    display: flex;
    gap: 4px;
    padding: 10px;
    border-bottom: 1px solid var(--gray-200);
}

.slot-btn {
    flex: 1;
    padding: 8px 4px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
}

.slot-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.slot-btn.has-image {
    border-color: var(--success);
}

.slot-btn .slot-icon {
    font-size: 20px;
    display: block;
    margin-bottom: 2px;
}

/* ═══════════════ SECCIONES DEL SIDEBAR ═══════════════ */
.section {
    border-bottom: 1px solid var(--gray-200);
    padding: 12px;
}

.section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

/* ═══════════════ BOTONES ═══════════════ */
.btn {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.btn + .btn {
    margin-top: 6px;
}

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

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

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

.btn-danger:hover {
    background: #b91c1c;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #15803d;
}

.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

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

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

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

.btn-group {
    display: flex;
    gap: 4px;
}

.btn-group .btn {
    flex: 1;
}

/* ═══════════════ CONTROLES DE FONDO ═══════════════ */
.bg-color-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid var(--gray-200);
    cursor: pointer;
    transition: all 0.2s;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* ═══════════════ SLIDERS ═══════════════ */
.slider-group {
    margin-bottom: 10px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 4px;
    color: var(--gray-600);
}

.slider-label span:last-child {
    font-weight: 600;
    color: var(--gray-800);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--gray-200);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ═══════════════ SELECTOR DE MODELO IA ═══════════════ */
select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: var(--gray-700);
    margin-bottom: 8px;
}

/* ═══════════════ ZONA CENTRAL - EDITOR ═══════════════ */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: var(--gray-100);
    position: relative;
    overflow: auto;
}

.canvas-container {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(var(--gray-200) 0% 25%, white 0% 50%) 50%/20px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
}

#mainCanvas {
    display: block;
}

.editor-toolbar {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    border: 1px solid var(--gray-200);
    margin: 8px auto;
    flex-shrink: 0;
    z-index: 10;
}

.editor-toolbar button {
    background: none;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

.editor-toolbar button:hover {
    background: var(--gray-100);
}

.editor-toolbar .separator {
    width: 1px;
    background: var(--gray-300);
    margin: 4px 6px;
}

.zoom-display {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    padding: 6px 8px;
    min-width: 50px;
    text-align: center;
}

.drop-zone {
    border: 3px dashed var(--gray-300);
    border-radius: 16px;
    padding: 60px 40px;
    text-align: center;
    color: var(--gray-400);
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.drop-zone .drop-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.drop-zone .drop-text {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.drop-zone .drop-hint {
    font-size: 13px;
}

/* ═══════════════ PANEL DERECHO - PREVIEW A4 ═══════════════ */
.sidebar-right {
    width: var(--preview-width);
    background: white;
    border-left: 1px solid var(--gray-200);
    overflow-y: auto;
    flex-shrink: 0;
    padding: 12px;
}

.preview-a4 {
    width: 100%;
    aspect-ratio: 210 / 297;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 12px;
    overflow: hidden;
}

.preview-a4 img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.format-selector {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.format-btn {
    flex: 1;
    padding: 6px 4px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
}

.format-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

/* ═══════════════ NOTIFICACIONES ═══════════════ */
.notification {
    position: fixed;
    top: 70px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.notification.success {
    background: var(--success);
    color: white;
}

.notification.error {
    background: var(--danger);
    color: white;
}

.notification.info {
    background: var(--primary);
    color: white;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ═══════════════ LOADING SPINNER ═══════════════ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: white;
    font-size: 16px;
    font-weight: 600;
    margin-top: 16px;
    text-align: center;
}

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

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 1024px) {
    .sidebar-right {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar-left {
        width: 220px;
    }
}

/* ═══════════════ ESTADO VACÍO ═══════════════ */
.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--gray-400);
}

.empty-state .empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

/* ═══════════════ MARCO OVERLAY ═══════════════ */
.frame-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    font-size: 12px;
    color: var(--gray-400);
    transition: all 0.2s;
}

.frame-upload-area:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ═══════════════ STATUS BAR ═══════════════ */
.status-bar {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    display: none;
}

.status-bar.visible {
    display: block;
}
