/* ==========================================================================
   1. VARIÁVEIS DE TEMA (DARK E LIGHT MODE)
   ========================================================================== */

/* Configurações Globais / Estruturais */
:root {
    --nav-height: 70px;
    --footer-height: 50px;
    --radius-card: 8px;
    --radius-input: 6px;
    --glass-blur: blur(16px);
    --success: #2eca6a;
}

/* TEMA ESCURO (Padrão e para as 18h - 07h59) */
:root[data-theme="dark"] {
    --bg-image: url('../img/fundo-dark.png');
    --primary: #c084fc; 
    --secondary: #22d3ee;
    --bg-main: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    
    /* Glassmorphism Dark */
    --glass-bg: rgba(15, 23, 42, 0.45);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    
    /* Elementos UI Dark */
    --icon-bg: rgba(255, 255, 255, 0.08);
    --icon-border: rgba(255, 255, 255, 0.1);
    --input-bg: transparent;
    --input-border: rgba(255, 255, 255, 0.2);
    --input-focus-bg: rgba(255, 255, 255, 0.05);
    --check-border: rgba(255, 255, 255, 0.3);
    --check-bg: rgba(255, 255, 255, 0.05);
    --check-mark: var(--bg-main);
    --btn-bg: #e2e8f0;
    --btn-hover: #ffffff;
    --btn-text: #0f172a;
}

/* TEMA CLARO SUAVE (Para as 08h - 17h59) */
:root[data-theme="light"] {
    --bg-image: url('../img/fundo-light.png');
    --primary: #4f46e5; 
    --secondary: #0284c7;
    --bg-main: #f1f5f9; 
    --text-main: #0f172a; 
    --text-muted: #334155; 
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.1);
    
    /* Glassmorphism Light */
    --glass-bg: rgba(255, 255, 255, 0.45); 
    --glass-border: rgba(255, 255, 255, 0.7);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    
    /* Elementos UI Light */
    --icon-bg: rgba(255, 255, 255, 0.8);
    --icon-border: rgba(15, 23, 42, 0.08);
    --input-bg: rgba(255, 255, 255, 0.6); 
    --input-border: rgba(15, 23, 42, 0.15);
    --input-focus-bg: rgba(255, 255, 255, 0.9);
    --check-border: rgba(15, 23, 42, 0.3);
    --check-bg: rgba(255, 255, 255, 0.6);
    --check-mark: #ffffff;
    --btn-bg: #1e293b;
    --btn-hover: #0f172a;
    --btn-text: #ffffff;
}

/* ==========================================================================
   2. BASE E LAYOUT
   ========================================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    transition: background-color 0.5s ease, color 0.5s ease;
}

body {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    transition: all 0.5s ease;
}

/* Toasts de Notificação */
.toast-item {
    pointer-events: auto;
    background: var(--input-focus-bg);
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-input);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateY(0);
    opacity: 1;
    transition: all 0.5s ease;
    color: var(--text-main);
}
.toast-item.border-green-500 { border-left-color: var(--success); }
.toast-item.border-red-500 { border-left-color: var(--danger); }

/* ==========================================================================
   3. NAVBAR FIXO
   ========================================================================== */
.navbar {
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 3rem;
    flex-shrink: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--glass-border);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    text-decoration: none;
}

.nav-secure {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ==========================================================================
   4. ÁREA PRINCIPAL E SHOWCASE
   ========================================================================== */
.main-content {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 8%;
    overflow-y: auto;
    gap: 2rem;
}

.brand-showcase {
    flex: 1;
    max-width: 550px;
    padding: 3rem;
    border-radius: var(--radius-card);
    animation: fadeIn 1s ease-out;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.brand-showcase h1 {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-showcase p {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.6;
    font-weight: 500;
}

/* ==========================================================================
   5. CARTÃO DE LOGIN E FORMULÁRIOS
   ========================================================================== */
.login-wrapper {
    flex-shrink: 0;
    width: 100%;
    max-width: 420px;
}

.login-card {
    border-radius: var(--radius-card);
    padding: 2.5rem;
    animation: slideLeft 0.6s ease-out;
    position: relative;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideLeft {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

.card-header { 
    text-align: center; 
    margin-bottom: 2.5rem; 
}

.lock-icon-container {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.5rem auto;
    border-radius: 50%;
    background: var(--icon-bg);
    border: 1px solid var(--icon-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    transition: all 0.3s;
}

.card-title { font-size: 1.5rem; font-weight: 700; color: var(--text-main); }
.card-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 6px; }

.form-group { margin-bottom: 1.25rem; }

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.3s;
    display: flex;
}

.form-control {
    width: 100%;
    padding: 0.9rem 1rem 0.9rem 2.8rem;
    font-size: 0.95rem;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-input);
    transition: all 0.3s;
    background-color: var(--input-bg);
    color: var(--text-main);
}

.input-with-icon:focus-within .input-icon { color: var(--primary); }

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--input-focus-bg);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.form-control::placeholder { color: var(--text-muted); opacity: 0.8; }

/* Selects */
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='gray' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
}

.btn-toggle-view {
    position: absolute;
    right: 12px;
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    transition: color 0.3s;
}
.btn-toggle-view:hover { color: var(--text-main); }

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    font-weight: 500;
}

.remember-me input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--check-border);
    border-radius: 4px;
    background-color: var(--check-bg);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.remember-me input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.remember-me input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid var(--check-mark);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.forgot-password {
    color: var(--secondary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}
.forgot-password:hover { color: var(--text-main); }

.btn-submit {
    width: 100%;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    font-weight: 700;
    font-size: 1rem;
    padding: 0.9rem;
    border: none;
    border-radius: var(--radius-input);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
.btn-submit:hover { 
    background-color: var(--btn-hover); 
    transform: translateY(-2px); 
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.btn-submit:disabled { 
    background-color: var(--text-muted); 
    color: var(--bg-main);
    cursor: not-allowed; 
    transform: none; 
    box-shadow: none;
}

.register-section {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}
.register-section a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.3s;
}
.register-section a:hover { color: var(--text-main); }

/* ==========================================================================
   6. FOOTER E SPINNER
   ========================================================================== */
.footer {
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex-shrink: 0;
    border-top: 1px solid var(--glass-border);
    font-weight: 500;
}
.footer a {
    color: var(--text-main);
    text-decoration: none;
    margin-left: 4px;
    font-weight: 600;
}

.spinner {
    width: 20px; height: 20px;
    border: 2px solid rgba(0,0,0,0.1);
    border-top-color: var(--btn-text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   7. WIZARD E REGISTO COMPACTO (STEPS & GRID)
   ========================================================================== */

/* Wrapper mais largo para o Registo */
.register-wrapper {
    flex-shrink: 0;
    width: 100%;
    max-width: 750px;
}
.register-wrapper .login-card {
    padding: 1.5rem 2.5rem;
}
.register-wrapper .card-header {
    margin-bottom: 1rem;
}
.register-wrapper .card-header .lock-icon-container {
    width: 40px;
    height: 40px;
    margin-bottom: 0.5rem;
}
.register-wrapper .card-title {
    font-size: 1.3rem;
}
.register-wrapper .card-subtitle {
    margin-top: 0;
    font-size: 0.8rem;
}

/* Grid de Registo (2 Colunas, sem margem extra nos inputs) */
.register-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem 1rem;
}
.register-grid .form-group {
    margin-bottom: 0; 
}
.register-grid label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

/* Inputs Compactos para não haver Scroll */
.form-control.compact {
    padding: 0.35rem 0.75rem 0.35rem 2.25rem;
    font-size: 0.75rem;
    height: 34px;
}
.input-with-icon.compact .input-icon {
    left: 10px;
}
.input-with-icon.compact .input-icon i,
.input-with-icon.compact .input-icon svg {
    font-size: 0.85rem;
    width: 14px;
    height: 14px;
}
.input-with-icon.compact .btn-toggle-view {
    right: 8px;
}
select.form-control.compact {
    background-position: right 0.5rem center;
    background-size: 10px;
}

/* Add-on de Telefone */
.select-addon {
    border-radius: var(--radius-input) 0 0 var(--radius-input);
    max-width: 75px;
    border-right: 0;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--input-border);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}
.input-addon-right {
    border-radius: 0 var(--radius-input) var(--radius-input) 0;
    padding-left: 0.75rem;
}

/* Botões do Wizard */
.btn-submit.compact {
    width: auto;
    padding: 8px 24px;
    font-size: 0.85rem;
}
.btn-voltar {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-input);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
}
.btn-voltar:hover {
    background: var(--input-focus-bg);
    color: var(--text-main);
    border-color: var(--text-muted);
}

/* Lógica das Abas do Wizard */
.step-content {
    display: none;
    animation: fadeInStep 0.4s ease forwards;
}
.step-content.active {
    display: block;
}
@keyframes fadeInStep {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Indicadores Superiores */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    position: relative;
    padding: 0 1rem;
}
.step-indicator::before {
    content: '';
    position: absolute;
    top: 13px;
    left: 2rem;
    right: 2rem;
    height: 2px;
    background: var(--glass-border);
    z-index: 1;
}
.step-item {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}
.step-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: all 0.3s ease;
}
.step-item.active .step-circle {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 0 4px rgba(65, 84, 241, 0.2);
}
.step-item.completed .step-circle {
    border-color: var(--success);
    background: var(--success);
    color: #ffffff;
}
.step-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    transition: color 0.3s;
}
.step-item.active .step-label { color: var(--text-main); }
.step-item.completed .step-label { color: var(--success); }

/* Feedback Pass Match */
.pass-match-msg {
    font-size: 0.65rem;
    font-weight: 700;
    display: block;
    height: 12px;
    margin-top: 4px;
}

/* Ajustes Dark Mode Secíficos do Registo */
[data-theme="dark"] .step-circle { background: var(--bg-main); }
[data-theme="dark"] .btn-voltar { border-color: var(--input-border); color: var(--text-muted); }
[data-theme="dark"] .btn-voltar:hover { background: var(--input-focus-bg); color: var(--text-main); }

/* ==========================================================================
   8. MEDIA QUERIES (RESPONSIVO)
   ========================================================================== */
@media (max-width: 900px) {
    .brand-showcase { display: none; }
    .main-content { justify-content: center; padding: 2rem 1.5rem; }
    .login-wrapper, .register-wrapper { max-width: 100%; }
}

@media (max-width: 640px) {
    .register-grid { grid-template-columns: 1fr; }
}