/* ================================
   VARIABLES Y RESET
================================ */
:root {
    --verde-primary: #1e7e34;
    --verde-light: #28a745;
    --verde-bright: #48bb78;
    --verde-glow: rgba(40,167,69,0.25);
    --dark-bg: #0d1117;
    --dark-card: #161b22;
    --dark-card2: #1c2128;
    --dark-border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent-blue: #388bfd;
    --accent-orange: #d29922;
    --accent-red: #f85149;
    --accent-yellow: #e3b341;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 24px rgba(1,4,9,0.8);
    --shadow-sm: 0 4px 12px rgba(1,4,9,0.4);
    --transition: all 0.25s ease;
}

/* MODO CLARO */
body.light-mode {
    --dark-bg: #f0f4f8;
    --dark-card: #ffffff;
    --dark-card2: #f8fafc;
    --dark-border: #e2e8f0;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --shadow: 0 8px 24px rgba(0,0,0,0.1);
    --shadow-sm: 0 4px 12px rgba(0,0,0,0.06);
}

body.light-mode .auth-bg {
    background: linear-gradient(135deg, #1a3d20 0%, #2d6a35 40%, #1e5228 100%);
}

body.light-mode .admin-navbar {
    background: linear-gradient(90deg, #1a202c, #2d3748);
}

body.light-mode .admin-table th {
    background: #f8fafc;
    color: #4a5568;
}

body.light-mode .input-group input,
body.light-mode .input-group select {
    background: #f8fafc;
    color: #1a202c;
    border-color: #e2e8f0;
}

body.light-mode .input-group input::placeholder {
    color: #a0aec0;
}

body.light-mode .input-group input:focus,
body.light-mode .input-group select:focus {
    background: #ffffff;
    border-color: var(--verde-light);
}

body.light-mode .auth-card {
    background: rgba(255,255,255,0.95);
    border-color: rgba(226,232,240,0.8);
}

body.light-mode .auth-card h2 {
    color: #1a202c;
}

body.light-mode .auth-title {
    color: #fff;
}

body.light-mode .historial-toggle:hover {
    background: rgba(0,0,0,0.02);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ================================
   SPLASH SCREEN
================================ */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a1628 0%, #0d2137 40%, #0a1f0f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.splash-logo {
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, #1e7e34, #48bb78);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: #fff;
    margin-bottom: 24px;
    box-shadow: 0 0 60px rgba(40,167,69,0.5);
    animation: splashFloat 2s ease-in-out infinite;
}

@keyframes splashFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-12px) scale(1.05); }
}

.splash-title {
    font-size: 44px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.splash-title span { color: #48bb78; }

.splash-subtitle {
    font-size: 14px;
    color: rgba(255,255,255,0.45);
    margin-bottom: 48px;
    letter-spacing: 0.5px;
}

.splash-progress-container {
    width: 260px;
    height: 3px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 20px;
}

.splash-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1e7e34, #48bb78, #1e7e34);
    background-size: 200% 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.splash-status {
    font-size: 13px;
    color: rgba(255,255,255,0.45);
    font-weight: 500;
    min-height: 20px;
    transition: opacity 0.3s ease;
    letter-spacing: 0.3px;
}

/* ================================
   BOTÓN TEMA
================================ */
.theme-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: var(--dark-card);
    border: 1px solid var(--dark-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    font-size: 20px;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(20deg);
    border-color: var(--verde-light);
    box-shadow: 0 4px 20px var(--verde-glow);
}

/* ================================
   PÁGINAS
================================ */
.page { display:none; min-height:100vh; }
.page.active { display:block; }

/* ================================
   AUTH LAYOUT
================================ */
.auth-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a1628 0%, #0d2137 35%, #0a1f0f 70%, #061210 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    position: relative;
    overflow: hidden;
}

.auth-bg::before {
    content: '';
    position: absolute;
    top: -30%;
    left: -20%;
    width: 60%;
    height: 80%;
    background: radial-gradient(circle, rgba(40,167,69,0.15) 0%, transparent 65%);
    pointer-events: none;
    animation: bgPulse 6s ease-in-out infinite;
}

.auth-bg::after {
    content: '';
    position: absolute;
    bottom: -20%;
    right: -10%;
    width: 50%;
    height: 70%;
    background: radial-gradient(circle, rgba(56,139,253,0.08) 0%, transparent 65%);
    pointer-events: none;
    animation: bgPulse 8s ease-in-out infinite reverse;
}

@keyframes bgPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.6; }
}

.auth-center {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 460px;
}

.auth-logo {
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, #1e7e34, #48bb78);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: #fff;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(40,167,69,0.4);
    animation: authFloat 4s ease-in-out infinite;
}

@keyframes authFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.auth-title {
    font-size: 34px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    text-align: center;
}

.auth-title span { color: #48bb78; }

.auth-subtitle {
    font-size: 13px;
    color: rgba(255,255,255,0.45);
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.6;
    max-width: 340px;
}

.auth-card {
    width: 100%;
    background: rgba(22,27,34,0.92);
    border: 1px solid rgba(48,54,61,0.8);
    border-radius: 16px;
    padding: 32px 36px;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    margin-bottom: 24px;
}

.auth-card h2 {
    font-size: 22px;
    font-weight: 700;
    color: #e6edf3;
    margin-bottom: 4px;
}

.auth-features {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.auth-feature {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 20px;
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    font-weight: 500;
    transition: var(--transition);
}

.auth-feature:hover {
    background: rgba(40,167,69,0.1);
    border-color: rgba(72,187,120,0.2);
    color: #48bb78;
}

.auth-feature i { color: #48bb78; font-size: 12px; }

/* ================================
   FORM
================================ */
.form-subtitle { font-size:13px; color:var(--text-secondary); margin-bottom:20px; }

/* ================================
   INPUTS
================================ */
.input-group {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.input-group i:first-child {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 13px;
    z-index: 1;
    transition: var(--transition);
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 12px 14px 12px 40px;
    background: var(--dark-bg);
    border: 1px solid var(--dark-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

.input-group input::placeholder { color:var(--text-muted); }

.input-group input:focus,
.input-group select:focus {
    border-color: var(--verde-light);
    background: var(--dark-card2);
    box-shadow: 0 0 0 3px var(--verde-glow);
}

.input-group:focus-within i:first-child { color:var(--verde-bright); }

.input-group select {
    appearance: none;
    cursor: pointer;
    color: var(--text-primary);
}

.input-group select option { background:var(--dark-card); color:var(--text-primary); }

.toggle-pass {
    position: absolute;
    right: 14px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.toggle-pass:hover { color:var(--verde-bright); }

/* ================================
   BOTONES
================================ */
.btn-primary {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, var(--verde-primary), var(--verde-light));
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 6px;
    box-shadow: 0 4px 14px var(--verde-glow);
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::after { left: 100%; }

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--verde-glow);
}

.btn-primary:active { transform:translateY(0); }
.btn-primary:disabled { opacity:0.6; cursor:not-allowed; transform:none; }

.btn-secondary {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--dark-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--verde-light);
    color: var(--verde-bright);
    background: rgba(40,167,69,0.06);
}

.divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0;
}

.divider::before,
.divider::after { content:''; flex:1; height:1px; background:var(--dark-border); }
.divider span { font-size:12px; color:var(--text-muted); white-space:nowrap; }

/* ================================
   NAVBAR
================================ */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 60px;
    background: var(--dark-card);
    border-bottom: 1px solid var(--dark-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-navbar {
    background: linear-gradient(90deg, #0d1117, #161b22);
    border-bottom: 1px solid #388bfd22;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.nav-brand i { color:var(--verde-bright); font-size:19px; }

.nav-user { display:flex; align-items:center; gap:10px; font-size:14px; color:var(--text-secondary); }

.nav-avatar {
    width: 32px;
    height: 32px;
    background: rgba(40,167,69,0.15);
    border: 1px solid rgba(40,167,69,0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--verde-bright);
}

.admin-avatar {
    background: rgba(56,139,253,0.15);
    border-color: rgba(56,139,253,0.3);
    color: #388bfd;
}

.btn-logout {
    padding: 7px 14px;
    background: rgba(248,81,73,0.1);
    border: 1px solid rgba(248,81,73,0.25);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    color: var(--accent-red);
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(248,81,73,0.2);
    border-color: var(--accent-red);
}

/* ================================
   DASHBOARD
================================ */
.dashboard-container { max-width:900px; margin:0 auto; padding:28px 20px; }

.dashboard-card {
    background: var(--dark-card);
    border: 1px solid var(--dark-border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.dashboard-card:hover {
    border-color: rgba(40,167,69,0.2);
}

.card-header-dash {
    padding: 20px 24px;
    border-bottom: 1px solid var(--dark-border);
    display: flex;
    align-items: center;
    gap: 14px;
}

.card-icon {
    width: 38px;
    height: 38px;
    background: rgba(40,167,69,0.12);
    border: 1px solid rgba(40,167,69,0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--verde-bright);
    flex-shrink: 0;
}

.card-header-dash h3 { font-size:16px; font-weight:600; color:var(--text-primary); }
.card-header-dash p { font-size:12px; color:var(--text-secondary); margin-top:2px; }

/* ================================
   HISTORIAL TOGGLE
================================ */
.historial-toggle {
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    border-bottom: none;
}

.historial-toggle:hover { background:rgba(255,255,255,0.02); }

.historial-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(40,167,69,0.1);
    border: 1px solid rgba(40,167,69,0.2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--verde-bright);
    white-space: nowrap;
    transition: var(--transition);
}

.historial-toggle:hover .historial-btn {
    background: rgba(40,167,69,0.2);
}

#historial-chevron { transition: transform 0.3s ease; font-size:11px; }

/* ================================
   UPLOAD ZONE
================================ */
.upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 44px 24px;
    margin: 20px 24px;
    border: 2px dashed var(--dark-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.upload-zone:hover {
    border-color: var(--verde-light);
    background: rgba(40,167,69,0.04);
}

.upload-icon-wrapper {
    width: 64px;
    height: 64px;
    background: rgba(40,167,69,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    transition: var(--transition);
}

.upload-zone:hover .upload-icon-wrapper {
    background: rgba(40,167,69,0.2);
    transform: translateY(-3px);
}

.upload-icon { font-size:28px; color:var(--verde-bright); }
.upload-zone p { font-size:15px; color:var(--text-secondary); margin-bottom:6px; font-weight:500; }
.upload-zone span { font-size:12px; color:var(--text-muted); margin-bottom:14px; display:block; }

.btn-upload {
    padding: 9px 22px;
    background: linear-gradient(135deg, var(--verde-primary), var(--verde-light));
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 10px var(--verde-glow);
}

.btn-upload:hover { transform:translateY(-2px); box-shadow:0 6px 16px var(--verde-glow); }

#preview-img {
    max-width: calc(100% - 48px);
    max-height: 280px;
    object-fit: cover;
    border-radius: var(--radius);
    margin: 0 24px 16px;
    border: 1px solid var(--dark-border);
    display: block;
}

.btn-analizar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: calc(100% - 48px);
    margin: 0 24px 20px;
    padding: 13px;
    background: linear-gradient(135deg, var(--verde-primary), var(--verde-light));
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px var(--verde-glow);
}

.btn-analizar:hover { transform:translateY(-2px); box-shadow:0 6px 20px var(--verde-glow); }

#resultado-box { padding:0 24px 24px; }

/* ================================
   VALIDACIONES
================================ */
.field-error {
    color: #f85149;
    font-size: 11px;
    margin-top: -2px;
    margin-bottom: 8px;
    padding-left: 2px;
    min-height: 16px;
}

.input-group input.invalid,
.input-group select.invalid {
    border-color: #f85149;
    background: rgba(248,81,73,0.05);
}

.input-group input.valid,
.input-group select.valid {
    border-color: var(--verde-light);
    background: rgba(40,167,69,0.05);
}

/* ================================
   HINTS CONTRASEÑA
================================ */
.password-hints {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: -2px;
    margin-bottom: 10px;
    padding-left: 2px;
}

.hint { font-size:11px; color:#f85149; transition:var(--transition); }
.hint.ok { color:var(--verde-bright); }

/* ================================
   STATS ADMIN
================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 24px 20px;
    border-radius: var(--radius);
    text-align: center;
    border: 1px solid transparent;
    transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); }

.stat-green {
    background: rgba(40,167,69,0.1);
    border-color: rgba(40,167,69,0.2);
    color: var(--verde-bright);
}

.stat-blue {
    background: rgba(56,139,253,0.1);
    border-color: rgba(56,139,253,0.2);
    color: #388bfd;
}

.stat-orange {
    background: rgba(210,153,34,0.1);
    border-color: rgba(210,153,34,0.2);
    color: var(--accent-yellow);
}

.stat-card i { font-size:26px; margin-bottom:10px; display:block; opacity:0.9; }
.stat-number { font-size:38px; font-weight:700; line-height:1; margin-bottom:6px; }
.stat-label { font-size:12px; opacity:0.8; color:var(--text-secondary); }

/* ================================
   TABLAS ADMIN
================================ */
.admin-table { width:100%; border-collapse:collapse; font-size:13px; font-family:'Poppins',sans-serif; }

.admin-table th {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--dark-border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--dark-card2);
}

.admin-table td {
    padding: 13px 16px;
    border-bottom: 1px solid rgba(48,54,61,0.5);
    color: var(--text-secondary);
    vertical-align: middle;
}

.admin-table tr:hover td {
    background: rgba(255,255,255,0.02);
    color: var(--text-primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-blue { background:rgba(56,139,253,0.15); color:#388bfd; border:1px solid rgba(56,139,253,0.25); }
.badge-green { background:rgba(40,167,69,0.15); color:var(--verde-bright); border:1px solid rgba(40,167,69,0.25); }
.badge-red { background:rgba(248,81,73,0.15); color:#f85149; border:1px solid rgba(248,81,73,0.25); }
.badge-orange { background:rgba(210,153,34,0.15); color:var(--accent-yellow); border:1px solid rgba(210,153,34,0.25); }
.badge-gray { background:rgba(72,79,88,0.2); color:var(--text-muted); border:1px solid rgba(72,79,88,0.3); }

/* ================================
   RESPONSIVE
================================ */
@media (max-width: 768px) {
    .auth-card { padding:24px 20px; }
    .auth-title { font-size:28px; }
    .auth-features { gap:8px; }
    .dashboard-container { padding:16px 12px; }
    .navbar { padding:0 16px; }
    .stats-grid { grid-template-columns:1fr; }
    .card-header-dash { padding:16px 18px; }
    .upload-zone { margin:16px; padding:32px 16px; }
    #resultado-box { padding:0 16px 16px; }
    #preview-img { margin:0 16px 12px; max-width:calc(100% - 32px); }
    .btn-analizar { width:calc(100% - 32px); margin:0 16px 16px; }
    .theme-toggle { bottom:16px; right:16px; width:42px; height:42px; }
}

@media (max-width: 480px) {
    .auth-center { max-width:100%; }
    .auth-card { border-radius:12px; padding:20px 16px; }
    .nav-brand span { font-size:15px; }
    .historial-btn span { display:none; }
}