/* --- VARIABLES GLOBALES (Tomadas de index.html) --- */
:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-main: #f5f5f5;
    --text-muted: #a0a0a0;
    --accent-red: #d32f2f;
    --accent-red-hover: #b71c1c;
    --accent-blue: #2196F3;
    --input-bg: #2c2c2c;
    --input-border: #444;
    --success-color: #4CAF50;
    --error-color: #f44336;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 12px;
}

/* --- CONTENEDORES --- */
.container {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 672px; /* Ancho ideal para el formulario grid */
    transition: all 0.5s;
    margin: 40px auto;
}

.hidden {
    display: none !important;
}

/* --- TIPOGRAFÍA Y ENCABEZADOS --- */
.header {
    text-align: center;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--input-border);
    padding-bottom: 16px;
}

.header .header-icon {
    font-size: 40px;
    color: var(--accent-red);
    margin-bottom: 8px;
}

.header h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-main);
}

.header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.section-title {
    color: var(--text-muted);
    font-size: 13px;
    text-align: left;
    margin: 20px 0 12px 0;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-section {
    margin-bottom: 24px;
}

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

.form-input {
    width: 100%;
    padding: 12px 14px;
    background-color: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.2);
}

textarea.form-input {
    min-height: 120px;
    resize: vertical;
}

/* --- SISTEMA GRID --- */
.form-grid {
    display: grid;
    gap: 16px;
    margin-top: 10px;
}

.grid-cols-md-2 {
    grid-template-columns: 1fr;
}
.grid-cols-md-3 {
    grid-template-columns: 1fr;
}

@media (min-width: 600px) {
    .grid-cols-md-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-md-3 { grid-template-columns: 1fr 2fr; } /* Proporción para el título y nombre */
}

/* --- UTILIDADES --- */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.py-4 { padding: 24px 0; }
.py-5 { padding: 40px 0; }
.text-center { text-align: center; }

/* --- PREVISUALIZACIÓN DE CARPETA --- */
.preview-box {
    background-color: rgba(33, 150, 243, 0.1);
    border: 1px dashed var(--accent-blue);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.preview-text {
    font-weight: 600;
    color: var(--accent-blue);
    word-break: break-all;
    font-size: 16px;
}

/* --- BOTONES --- */
.btn-primary, .btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    gap: 10px;
}

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

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

.btn-primary:disabled {
    background-color: #525252;
    color: #888;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--input-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: var(--input-bg);
    border-color: var(--text-main);
}

/* --- PANTALLA DE CARGA / SPINNER --- */
.spinning-icon {
    font-size: 50px;
    color: var(--accent-red);
    animation: spin 1.5s linear infinite;
}

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

.loading-text {
    color: var(--text-muted);
    font-size: 16px;
    margin-top: 16px;
}

/* --- PANTALLA DE ÉXITO Y ANIMACIÓN CHECK --- */
.success-title {
    font-size: 24px;
    color: var(--text-main);
    margin-top: 16px;
}

.success-text {
    color: var(--text-muted);
    margin-top: 8px;
}

#success-link-container a {
    color: var(--accent-blue);
    font-weight: 600;
    text-decoration: underline;
    font-size: 16px;
}

.success-checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 3;
    stroke: var(--success-color);
    stroke-miterlimit: 10;
    margin: 0 auto;
    box-shadow: inset 0px 0px 0px var(--success-color);
    animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both;
}

.success-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 3;
    stroke-miterlimit: 10;
    stroke: var(--success-color);
    fill: none;
    animation: stroke .6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke: #ffffff;
    animation: stroke .3s cubic-bezier(0.65, 0, 0.45, 1) .8s forwards;
}

@keyframes stroke {
    100% { stroke-dashoffset: 0; }
}

@keyframes scale {
    0%, 100% { transform: none; }
    50% { transform: scale3d(1.1, 1.1, 1); }
}

@keyframes fill {
    100% { box-shadow: inset 0px 0px 0px 40px var(--success-color); }
}

/* --- MENSAJES DE ESTADO --- */
#status-message {
    margin-top: 20px;
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    display: none;
    /* ESTAS DOS LÍNEAS ARREGLAN EL DESBORDE */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.status-success {
    display: block;
    color: var(--success-color);
    background-color: rgba(76, 175, 80, 0.1);
    border: 1px solid var(--success-color);
}

.status-error {
    display: block;
    color: var(--error-color);
    background-color: rgba(244, 67, 54, 0.1);
    border: 1px solid var(--error-color);
}





/* =========================================
   CUSTOM DROPDOWN (Reemplazo del Datalist)
   ========================================= */
.custom-dropdown-container {
    position: relative;
}

.custom-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    margin-top: 5px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 1000;
    list-style: none;
    padding: 0;
    box-shadow: 0 8px 16px rgba(0,0,0,0.6);
}

.custom-dropdown li {
    padding: 12px 14px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 14px;
    border-bottom: 1px solid #333;
    transition: background-color 0.2s ease;
}

.custom-dropdown li:last-child {
    border-bottom: none;
}

.custom-dropdown li:hover {
    background-color: var(--accent-red);
    color: white;
}



/* ==========================================================================
   ESTÁNDAR DE PANTALLA DE CARGA (LOADER) MANTONET
   ========================================================================== */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(18, 18, 18, 0.85); /* Gris oscuro translúcido */
    backdrop-filter: blur(4px); /* Desenfoque tipo iOS/Glassmorphism */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.loader-overlay.hidden {
    display: none !important;
    opacity: 0;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90%;
    max-width: 350px; /* Evita que se estire demasiado en PC */
}

/* 1. Animación del logo SVG en la pantalla de CARGA */
.loader-logo {
    width: 160px;  /* Antes era 90px. Súbelo a 160px o 200px según veas */
    height: 160px; /* Debe ser igual al width */
    margin-bottom: 25px;
    animation: pulse-logo 1.8s infinite ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(1.6); /* El zoom para quitar los márgenes transparentes del SVG */
}

@keyframes pulse-logo {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; filter: drop-shadow(0 0 12px rgba(211, 47, 47, 0.6)); }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* 2. Contenedor de la barra de progreso */
.loader-progress-container {
    width: 100%;
    height: 6px;
    background-color: #333333;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
    position: relative;
}

/* 3. Barra de progreso dinámica */
.loader-progress-bar {
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, #b71c1c, #ff5252, #b71c1c);
    border-radius: 10px;
    position: absolute;
    left: 0;
    /* Animación por defecto (cuando no sabemos cuánto falta) */
    animation: loading-bar 1.5s infinite linear;
    transition: width 0.4s ease; /* Transición suave si usamos porcentaje */
}

@keyframes loading-bar {
    0% { left: -40%; width: 40%; }
    50% { left: 30%; width: 60%; }
    100% { left: 100%; width: 40%; }
}

/* 4. Textos de información perfectamente centrados */
.loader-title {
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-align: center;
    letter-spacing: 0.5px;
}

.loader-text {
    color: #a0a0a0;
    font-size: 14px;
    text-align: center;
    margin: 0;
    line-height: 1.4;
    white-space: pre-line; /* Respeta los saltos de línea \n */
}



/* ==========================================================================
   TAMAÑO Y ESCALADO DEL LOGO PRINCIPAL
   ========================================================================== */
#logoAnimado {
    width: 100%;
    height: 50px; /* Altura del contenedor. Puedes subirlo a 110px si lo quieres gigante */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    overflow: visible;
}

#logoAnimado img {
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    /* MAGIA AQUÍ: Esto hace un zoom al SVG para eliminar sus márgenes internos */
    transform: scale(1.5); 
}




    /* Botón de Regresar */
    .btn-back-home {
      position: absolute;
      top: 20px;
      left: 20px;
      color: #a0a0a0;
      text-decoration: none;
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 14px;
      font-weight: 600;
      transition: color 0.2s;
      z-index: 100;
    }

    .btn-back-home:hover {
      color: #fff;
    }

    /* Menú Autocompletado Oscuro */
    .custom-dropdown-container {
      position: relative;
    }

    .custom-dropdown {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      background-color: var(--input-bg, #2c2c2c);
      border: 1px solid var(--input-border, #444);
      border-radius: 8px;
      margin-top: 5px;
      max-height: 180px;
      overflow-y: auto;
      z-index: 1000;
      list-style: none;
      padding: 0;
      box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6);
    }

    .custom-dropdown li {
      padding: 12px 14px;
      cursor: pointer;
      color: var(--text-main, #f5f5f5);
      font-size: 14px;
      border-bottom: 1px solid #333;
    }

    .custom-dropdown li:hover {
      background-color: var(--accent-red, #d32f2f);
      color: white;
    }

    .custom-dropdown li:last-child {
      border-bottom: none;
    }

    /* Pestañas (Tabs) en Formato Grid (2 Columnas, 3er botón abajo) */
    .tabs-container {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin-bottom: 25px;
    }

    .tab-btn {
      padding: 12px;
      text-align: center;
      background: var(--input-bg, #2c2c2c);
      border: 1px solid var(--input-border, #444);
      color: var(--text-muted, #a0a0a0);
      border-radius: 8px;
      cursor: pointer;
      font-weight: 600;
      font-size: 13px;
      transition: all 0.3s;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
    }

    .tab-btn:hover {
      background: #3a3a3a;
    }

    .tab-btn.active {
      background: var(--accent-red, #d32f2f);
      color: white;
      border-color: var(--accent-red, #d32f2f);
    }

    /* Clase para que el botón de gestión ocupe todo el ancho inferior */
    .tab-btn.full-width {
      grid-column: 1 / -1;
    }

    /* Tarjeta Cliente */
    .client-card {
      background: #1a1a1a;
      border-left: 4px solid #16a34a;
      padding: 12px;
      border-radius: 6px;
      margin-top: 10px;
      display: none;
      font-size: 13px;
      color: #bbb;
    }

    .client-card strong {
      color: #fff;
      display: block;
      font-size: 14px;
      margin-bottom: 3px;
    }

    /* --- Contenedor Principal --- */
    .container {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;
      max-width: 550px;
    }