/* styles.css */

:root {
    --primary-bg: #1a1a1a;       /* Fondo oscuro fuera del lienzo */
    --panel-bg: rgba(30, 30, 35, 0.85); /* Panel semitransparente */
    --accent-color: #3b82f6;     /* Azul técnico */
    --danger-color: #ef4444;     /* Rojo alerta */
    --text-color: #f3f4f6;       /* Blanco suave */
    --border-color: #4b5563;     /* Gris borde */
}

body, html {
    margin: 0; padding: 0; height: 100%; width: 100%;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    background-color: var(--primary-bg);
}

/* --- BARRA DE CONTROL (ESTILO FLOTANTE) --- */
.top-bar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1000px;
    padding: 12px 20px;
    
    /* Efecto Cristal (Glassmorphism) */
    background: var(--panel-bg);
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 100;
    transition: all 0.3s ease;
}

/* --- ESTILO DE LOS SELECTS --- */
.select-group {
    position: relative;
    display: flex;
    align-items: center;
}

select {
    appearance: none; /* Quitar flecha por defecto */
    background-color: #2d2d35;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px 35px 10px 15px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    min-width: 160px;
    transition: border-color 0.2s, box-shadow 0.2s;
    /* Flecha SVG incrustada */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #1f1f23;
}

/* --- BOTÓN DE LIMPIAR --- */
button.btn-clean {
    background-color: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    padding: 9px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

button.btn-clean:hover {
    background-color: var(--danger-color);
    color: white;
    transform: translateY(-1px);
}

/* --- FONDO DEL LIENZO (PAPEL TÉCNICO) --- */
#canvas-wrapper {
    width: 100vw;
    height: 100vh;
    background-color: #f4f4f5; /* Papel casi blanco */
    /* Patrón de cuadrícula CSS puro */
    background-image: 
        linear-gradient(#e5e7eb 1px, transparent 1px), 
        linear-gradient(90deg, #e5e7eb 1px, transparent 1px);
    background-size: 20px 20px; /* Tamaño de la cuadrícula */
    background-position: center center;
}

/* --- RESPONSIVIDAD (MÓVIL) --- */
@media (max-width: 768px) {
    .top-bar {
        top: 0;
        width: 100%;
        border-radius: 0 0 12px 12px;
        flex-direction: column;
        align-items: stretch;
        padding: 15px 20px;
    }
    select { width: 100%; }
    button.btn-clean { justify-content: center; width: 100%; }
}

option {
    background-color: #2d2d35; /* Mismo gris oscuro del select */
    color: #f3f4f6;            /* Texto blanco */
    padding: 10px;
}

/* --- AGREGAR AL FINAL DE styles.css --- */

/* BOTÓN FLOTANTE ESTILO HP */
.fab-print {
    position: fixed;
    right: 30px;
    bottom: 30px;
    width: 60px;
    height: 60px;
    background-color: #ffffff;
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    z-index: 200; /* Por encima de todo */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Icono del botón */
.fab-print svg {
    width: 28px;
    height: 28px;
    fill: #333; /* Color gris oscuro HP */
    transition: fill 0.3s;
}

/* Efecto Hover (Al pasar el mouse) */
.fab-print:hover {
    transform: translateY(-5px); /* Se eleva un poco */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.fab-print:hover svg {
    fill: #0096D6; /* Azul HP al pasar el mouse */
}

/* Tooltip (Texto que aparece al lado) */
.fab-print::after {
    content: "Imprimir Plano";
    position: absolute;
    right: 75px;
    background: #333;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    white-space: nowrap;
}

.fab-print:hover::after {
    opacity: 1;
}

/* --- REGLAS DE IMPRESIÓN (LA MAGIA) --- */
@media print {
    /* 1. Ocultar todo lo que no sea el dibujo */
    .top-bar, .fab-print {
        display: none !important;
    }

    /* 2. Ajustar el lienzo al papel */
    body, html, #canvas-wrapper {
        background-color: white !important; /* Ahorra tinta, quita el gris */
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        overflow: visible;
    }

    /* Quitar la cuadrícula de fondo para imprimir limpio */
    #canvas-wrapper {
        background-image: none !important;
    }
}

/* =========================================
   EXTENSIÓN: PANEL DE ADMINISTRACIÓN
   (Pegar al final de styles.css)
   ========================================= */

/* Variable extra necesaria para los botones de guardar */
:root {
    --success-color: #10b981; 
}

/* Contenedor Principal Centrado */
.admin-container {
    position: relative;
    width: 90%;
    max-width: 900px;
    margin: 40px auto;
    height: calc(100vh - 80px); /* Resta espacio para margenes */
    overflow-y: auto; /* Scroll si es necesario */
    
    /* Mismo estilo Glassmorphism de tu barra superior */
    background: var(--panel-bg);
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    padding: 30px;
    display: grid;
    grid-template-columns: 1fr 1fr; /* Dos columnas */
    gap: 30px;
    color: var(--text-color);
}

/* Títulos de Sección */
.admin-container h2 {
    font-size: 18px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    margin-top: 0;
    color: var(--accent-color);
    grid-column: span 2; /* Títulos ocupan todo el ancho */
}

.admin-container h2 span {
    font-size: 0.8em;
    color: #9ca3af;
    font-weight: 400;
}

/* Cajas de las secciones individuales */
.form-section {
    background: rgba(0,0,0,0.2);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
}

.section-full-width {
    grid-column: 1 / -1; /* Ocupa todo el ancho */
}

/* Estilos para Inputs de Texto (igualando al diseño de tus Selects) */
input[type="text"], input[type="file"] {
    background-color: #2d2d35;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    width: 100%;
    box-sizing: border-box; 
    margin-bottom: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: 'Inter', sans-serif;
}

input[type="text"]:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Estilo especial para el input de archivo */
input[type="file"]::file-selector-button {
    background-color: var(--border-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    margin-right: 10px;
    cursor: pointer;
    transition: background 0.2s;
}
input[type="file"]::file-selector-button:hover {
    background-color: var(--accent-color);
}

/* Etiquetas */
label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Select Group dentro del form (ajuste de ancho) */
.form-section .select-group {
    width: 100%;
    margin-bottom: 15px;
}
.form-section select {
    width: 100%;
}

/* Botón de Acción (Guardar/Crear) */
.btn-action {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    margin-top: auto; 
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-action:hover {
    background-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-action svg {
    width: 18px;
    height: 18px;
}

/* Responsividad */
@media (max-width: 768px) {
    .admin-container {
        grid-template-columns: 1fr;
        height: auto;
        margin-top: 20px;
        padding: 20px;
    }
    
    .admin-container h2 {
        grid-column: span 1;
    }
}