/* ===== VARIABLES Y RESET ===== */
:root {
    --color-primary: #152648;
    --color-secondary: #2EBDEF;
    --color-white: #ffffff;
    --color-light-gray: #f8f9fa;
    --color-gray: #e9ecef;
    --color-dark-gray: #6c757d;
    --color-success: #28a745;
    --color-error: #dc3545;
    --border-radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--color-light-gray);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--color-primary) 0%, #1e3a6e 50%, #0d1f3c 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
}

/* Patrón decorativo de fondo */
.login-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(46,189,239,0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(46,189,239,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.login-box {
    background: rgba(255,255,255,0.97);
    border-radius: 16px;
    padding: 48px 44px 40px;
    max-width: 420px;
    width: 100%;
    box-shadow:
        0 20px 60px rgba(0,0,0,0.4),
        0 0 0 1px rgba(255,255,255,0.1);
    text-align: center;
    position: relative;
    animation: loginFadeIn 0.35s ease-out;
}

@keyframes loginFadeIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Franja decorativa superior */
.login-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-secondary), #1ca3d4);
    border-radius: 16px 16px 0 0;
}

.login-box .logo {
    height: 52px;
    margin-bottom: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.login-box h2 {
    color: var(--color-primary);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.login-subtitle {
    color: var(--color-dark-gray);
    font-size: 13.5px;
    margin-bottom: 32px;
    line-height: 1.5;
}

.login-group {
    margin-bottom: 18px;
    text-align: left;
}

.login-group label {
    display: block;
    margin-bottom: 7px;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-group input {
    width: 100%;
    padding: 13px 16px;
    border: 2px solid var(--color-gray);
    border-radius: 10px;
    font-size: 15px;
    color: var(--color-primary);
    background: var(--color-light-gray);
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.login-group input:focus {
    outline: none;
    border-color: var(--color-secondary);
    background: var(--color-white);
    box-shadow: 0 0 0 4px rgba(46,189,239,0.15);
}

.login-group input::placeholder {
    color: #b0bec5;
}

.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(220,53,69,0.08);
    border: 1px solid rgba(220,53,69,0.25);
    color: var(--color-error);
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
    text-align: left;
    animation: shake 0.35s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-5px); }
    40%       { transform: translateX(5px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--color-secondary) 0%, #1ca3d4 100%);
    color: var(--color-white);
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(46,189,239,0.4);
    margin-top: 8px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46,189,239,0.5);
    filter: brightness(1.05);
}

.btn-login:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(46,189,239,0.3);
}

.login-footer {
    margin-top: 24px;
    font-size: 12px;
    color: var(--color-dark-gray);
    opacity: 0.7;
}

/* ===== BOTÓN LOGOUT ===== */
.btn-logout {
    position: absolute;
    top: 18px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: var(--color-dark-gray);
    border: 1.5px solid var(--color-gray);
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-logout:hover {
    border-color: var(--color-error);
    color: var(--color-error);
    background: rgba(220,53,69,0.06);
}

.header {
    position: relative;
}

/* ===== BOTÓN ELIMINAR EN TABLA ===== */
.btn-delete-doc {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: transparent;
    color: var(--color-error);
    border: 1.5px solid rgba(220,53,69,0.5);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}

.btn-delete-doc:hover {
    background: var(--color-error);
    border-color: var(--color-error);
    color: white;
    box-shadow: 0 3px 10px rgba(220,53,69,0.3);
    transform: translateY(-1px);
}

.btn-delete-doc:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-delete-doc:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pdf-table .action-col {
    text-align: center;
    width: 110px;
}

/* Fila en proceso de eliminación */
.pdf-table tr.deleting {
    background: rgba(220,53,69,0.06) !important;
    transition: all 0.4s ease;
}

.pdf-table tr.deleted {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* ===== CONTENEDOR PRINCIPAL ===== */
.container {
    background: var(--color-white);
    border-radius: var(--border-radius);
    border: 1px solid var(--color-gray);
    padding: 40px;
    max-width: 650px;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ===== HEADER ===== */
.header {
    text-align: center;
    margin-bottom: 35px;
    padding-bottom: 25px;
    border-bottom: 3px solid var(--color-secondary);
}

.logo {
    height: 50px;
    margin-bottom: 15px;
}

h1 {
    color: var(--color-primary);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--color-dark-gray);
    font-size: 15px;
    font-weight: 400;
}

/* ===== FORMULARIO ===== */
.upload-form {
    margin-bottom: 25px;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 10px;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 14px;
}

/* ===== SELECT ===== */
select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--color-gray);
    border-radius: var(--border-radius);
    font-size: 15px;
    color: var(--color-primary);
    background-color: var(--color-white);
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23152648' d='M7 10L2 5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 45px;
    font-weight: 500;
}

select:hover {
    border-color: var(--color-secondary);
}

select:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(46, 189, 239, 0.15);
}

/* ===== FILE INPUT ===== */
.file-input-wrapper {
    position: relative;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: var(--color-light-gray);
    border: 2px dashed var(--color-gray);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--color-dark-gray);
    font-weight: 500;
    font-size: 15px;
    min-height: 100px;
    text-align: center;
}

.file-input-label:hover {
    background: rgba(46, 189, 239, 0.05);
    border-color: var(--color-secondary);
    color: var(--color-secondary);
}

.file-input-label.has-file {
    background: rgba(40, 167, 69, 0.05);
    border-color: var(--color-success);
    color: var(--color-success);
    border-style: solid;
}

.file-icon {
    font-size: 32px;
    margin-right: 12px;
}

/* ===== BOTÓN SUBMIT ===== */
.btn-submit {
    flex: 1;
    min-width: 200px;
    padding: 14px 24px;
    background: var(--color-secondary);
    color: var(--color-white);
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-submit:hover:not(:disabled) {
    background: #1ca3d4;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 189, 239, 0.3);
}

.btn-submit:active:not(:disabled) {
    background: #1890b8;
}

.btn-submit:disabled {
    background: var(--color-gray);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ===== MENSAJES ===== */
.message {
    margin-top: 20px;
    padding: 14px 18px;
    border-radius: var(--border-radius);
    display: none;
    font-size: 14px;
    font-weight: 500;
}

.message.success {
    background: rgba(40, 167, 69, 0.1);
    color: var(--color-success);
    border: 2px solid var(--color-success);
    display: block;
}

.message.error {
    background: rgba(220, 53, 69, 0.1);
    color: var(--color-error);
    border: 2px solid var(--color-error);
    display: block;
}

/* ===== ESTADÍSTICAS ===== */
.stats {
    margin-top: 30px;
    padding: 20px;
    background: var(--color-light-gray);
    border-radius: var(--border-radius);
    border: 2px solid var(--color-gray);
    display: none;
}

.stats.show {
    display: block;
}

.stats h3 {
    color: var(--color-primary);
    margin-bottom: 18px;
    font-size: 18px;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    gap: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--color-white);
    border-radius: var(--border-radius);
    border-left: 3px solid var(--color-secondary);
}

.stat-label {
    color: var(--color-dark-gray);
    font-size: 14px;
    font-weight: 500;
}

.stat-value {
    color: var(--color-primary);
    font-weight: 700;
    font-size: 15px;
}

/* ===== LISTA DE ARCHIVOS ===== */
.file-list {
    margin-top: 15px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background-color: var(--color-light-gray);
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 14px;
}

.file-item-icon {
    font-size: 18px;
}

.file-item-name {
    flex: 1;
    color: var(--color-primary);
    font-weight: 500;
}

.file-item-size {
    color: var(--color-dark-gray);
    font-size: 13px;
}

/* ===== DETALLES DE ARCHIVOS ===== */
.file-details {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-gray);
}

.file-details h4 {
    color: var(--color-primary);
    margin-bottom: 15px;
    font-size: 16px;
}

.success-list, .error-list {
    margin-bottom: 15px;
}

.success-list strong, .error-list strong {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
}

.file-detail-item {
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 5px;
    font-size: 13px;
}

.file-detail-item.success {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--color-success);
}

.file-detail-item.error {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--color-error);
}

/* ===== BOTONES ===== */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.btn-secondary {
    flex: 1;
    min-width: 200px;
    padding: 14px 24px;
    background-color: var(--color-white);
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background-color: var(--color-primary);
    color: var(--color-white);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(21, 38, 72, 0.2);
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background-color: var(--color-white);
    border-radius: var(--border-radius);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid var(--color-gray);
    background-color: var(--color-light-gray);
}

.modal-header h2 {
    color: var(--color-primary);
    font-size: 24px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--color-dark-gray);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--color-error);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
}

.pdf-list-content .loading,
.pdf-list-content .error,
.pdf-list-content .empty {
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
    color: var(--color-dark-gray);
}

.pdf-list-content .error {
    color: var(--color-error);
}

.pdf-list-content .empty {
    color: var(--color-dark-gray);
}

.pdf-summary {
    background-color: var(--color-light-gray);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
}

.pdf-summary p {
    margin: 0;
    color: var(--color-primary);
    font-size: 14px;
}

.pdf-summary strong {
    color: var(--color-secondary);
}

.pdf-table {
    overflow-x: auto;
}

.pdf-table table {
    width: 100%;
    border-collapse: collapse;
}

.pdf-table thead {
    background-color: var(--color-primary);
    color: var(--color-white);
}

.pdf-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.pdf-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--color-gray);
    font-size: 14px;
}

.pdf-table tr:hover {
    background-color: var(--color-light-gray);
}

.pdf-table .filename {
    font-weight: 500;
    color: var(--color-primary);
}

.pdf-table .category {
    font-weight: 500;
}

.pdf-table .topics {
    color: var(--color-dark-gray);
    font-size: 13px;
}

.pdf-table .chunks {
    text-align: center;
    font-weight: 600;
    color: var(--color-secondary);
}

/* ===== SPINNER ===== */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== MENSAJE DE ADVERTENCIA ===== */
.message.warning {
    background: rgba(255, 193, 7, 0.1);
    color: #ff9800;
    border: 2px solid #ff9800;
    display: block;
}

.message.info {
    background: rgba(46, 189, 239, 0.1);
    color: var(--color-secondary);
    border: 2px solid var(--color-secondary);
    display: block;
}

/* ===== PATH PREVIEW ===== */
.path-preview-text {
    background: linear-gradient(135deg, #e8f4f8 0%, #f0f8ff 100%);
    border: 1px solid var(--color-secondary);
    border-left: 4px solid var(--color-secondary);
    border-radius: var(--border-radius);
    padding: 12px 15px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--color-primary);
    font-weight: 500;
}

/* ===== SUBCATEGORY GROUP ===== */
#subcategoryGroup {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .container {
        padding: 30px 20px;
    }

    h1 {
        font-size: 24px;
    }

    .subtitle {
        font-size: 14px;
    }

    .file-input-label {
        padding: 25px 15px;
        min-height: 90px;
    }
}
