/* miniSYS-HGP — pantalla de login */
:root {
    --bg-body: #f1f3f5;
    --bg-card: #ffffff;
    --text-main: #212529;
    --text-muted: #868e96;
    --primary: #00609C;
    --primary-hover: #004a7a;
    --input-bg: #ffffff;
    --input-border: #ced4da;
    --input-text: #495057;
    --shadow: rgba(0,0,0,0.1);
    --brand-bg: #f8f9fa;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #121212;
        --bg-card: #1e1e1e;
        --text-main: #e9ecef;
        --text-muted: #adb5bd;
        --primary: #339af0;
        --primary-hover: #1c7ed6;
        --input-bg: #2c2e33;
        --input-border: #495057;
        --input-text: #f8f9fa;
        --shadow: rgba(0,0,0,0.5);
        --brand-bg: #181818;
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }

body {
    background: radial-gradient(circle at 20% 20%, rgba(0, 96, 156, 0.12), transparent 40%),
                radial-gradient(circle at 80% 80%, rgba(51, 154, 240, 0.1), transparent 35%),
                var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    transition: background-color 0.3s, color 0.3s;
}

.login-card {
    background-color: var(--bg-card);
    width: min(900px, 100%);
    min-height: 550px;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    border-radius: 16px;
    border: 1px solid var(--input-border);
    box-shadow: 0 20px 50px var(--shadow);
    overflow: hidden;
    position: relative;
}

.brand-section {
    width: 45%;
    background-color: var(--brand-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
    border-right: 1px solid var(--input-border);
    position: relative;
}

.brand-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: var(--primary);
}

.login-logo {
    width: 140px;
    height: 140px;
    object-fit: contain;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.brand-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    white-space: nowrap;
}

.brand-section p { font-size: 0.95rem; color: var(--text-muted); }

.form-section {
    width: 55%;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.form-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--bg-body);
    color: var(--text-main);
    white-space: nowrap;
}

.input-group { margin-bottom: 1.5rem; position: relative; }

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.input-wrapper { position: relative; }

.input-wrapper i.icon-left {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

input {
    width: 100%;
    padding: 14px 14px 14px 45px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--input-text);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 96, 156, 0.15);
}

.toggle-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
}

.toggle-btn:hover { color: var(--primary); }

.btn-login {
    width: 100%;
    padding: 15px;
    background-color: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.2s;
}

.btn-login:hover { background-color: var(--primary-hover); transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }

.version {
    margin-top: auto;
    padding-top: 2rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}

@media (max-width: 768px) {
    body {
        align-items: flex-start;
        padding: 0;
    }

    .login-card {
        flex-direction: column;
        width: 100%;
        min-height: 100%;
        max-width: 100%;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
    }

    .brand-section {
        width: 100%;
        height: auto;
        padding: 1.5rem 1rem;
        flex-shrink: 0;
        flex-direction: row;
        gap: 15px;
        border-right: none;
        border-bottom: 1px solid var(--input-border);
        justify-content: flex-start;
        text-align: left;
    }

    .brand-section::before { width: 100%; height: 4px; }

    .login-logo { width: 50px; height: 50px; margin-bottom: 0; }
    .brand-text-wrapper { display: flex; flex-direction: column; }
    .brand-section h2 { font-size: 1.1rem; margin: 0; }
    .brand-section p { font-size: 0.8rem; margin: 0; }

    .form-section {
        width: 100%;
        flex-grow: 1;
        padding: 1.5rem;
        justify-content: flex-start;
        overflow-y: auto;
    }

    .form-title { margin-top: 1rem; font-size: 1.1rem; }
    .btn-login { padding: 12px; margin-bottom: 2rem; }
}

@media (max-width: 480px) {
    body { padding: 0; }
    .form-section { padding: 1rem; }
    .form-title { margin-top: 0.5rem; margin-bottom: 1.2rem; }
    .brand-section h2 { font-size: 1rem; white-space: normal; }
    .toast {
        min-width: auto;
        width: calc(100vw - 24px);
        bottom: 12px;
        padding: 14px 16px;
    }
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
}

@media (prefers-color-scheme: dark) {
    .loading-overlay { background: rgba(0,0,0,0.8); }
}

.loading-overlay.active { display: flex; }

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--input-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 0.9rem;
    opacity: 0;
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
    white-space: normal;
    width: auto;
    max-width: 90vw;
    min-width: 300px;
    line-height: 1.5;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: #e03131; }
.toast.info { background: #1971c2; }
