/* ==========================================================================
   Design System & Zmienne
   ========================================================================== */
:root {
    /* Kolory tła i paneli (Ciemne) */
    --bg-dark: #07070a;
    --card-bg: rgba(13, 13, 21, 0.55);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-glow: rgba(0, 242, 254, 0.15);
    
    /* Tekst */
    --text-primary: #ffffff;
    --text-secondary: #8e90a6;
    --text-muted: #57596e;

    /* Kolory Neonowe (Glow) */
    --neon-cyan: #00f2fe;
    --neon-magenta: #ff0844;
    --neon-purple: #b10dc9;
    --neon-yellow: #ffb199;
    --neon-green: #00ff87;

    /* Gradienty */
    --grad-primary: linear-gradient(135deg, #00f2fe 0%, #ff0844 100%);
    --grad-input-focus: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
    --grad-button-hover: linear-gradient(135deg, #4facfe 0%, #ff0844 100%);
    
    /* Transition */
    --transition-smooth: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-bounce: all 0.5s cubic-bezier(0.68, -0.6, 0.32, 1.6);
}

/* ==========================================================================
   Resety i Style Globalne
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-dark);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Canvas dla neonowego tła kryształów */
#neon-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: auto; /* Obsługuje interakcję z myszką */
}

/* Login view wrapper */
#login-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

/* ==========================================================================
   Kontener Główny i Karta Logowania (Glassmorphism)
   ========================================================================== */
.login-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 480px;
    padding: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Glassmorphism Panel */
.login-card {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 40px 32px 32px 32px;
    position: relative;
    overflow: hidden;
    
    /* Złożony efekt szklany: rozmycie tła + cienie neonowe i głębokie */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 
        0 4px 30px rgba(0, 0, 0, 0.4),
        0 1px 0 rgba(255, 255, 255, 0.1) inset,
        0 0 32px rgba(0, 242, 254, 0.05),
        0 0 64px rgba(255, 8, 68, 0.03);
        
    transition: var(--transition-smooth);
}

/* Neonowy pasek dekoracyjny u góry karty */
.card-glow-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: var(--grad-primary);
    box-shadow: 0 2px 10px rgba(0, 242, 254, 0.4);
}

/* Ambient glow za panelem (delikatne światło) */
.login-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 242, 254, 0.05) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
}

/* Dynamiczny odrzut panelu przy błędzie (shake) */
.login-card.shake {
    animation: cardShake 0.4s ease-in-out;
}

/* Przejście wejścia panelu */
@keyframes cardShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

/* Nagłówek panelu */
.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    background: linear-gradient(180deg, #ffffff 50%, #b8bacc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.925rem;
    font-weight: 400;
}

/* ==========================================================================
   Pola Wejściowe (Inputy)
   ========================================================================== */
.input-group {
    margin-bottom: 24px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.input-label {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: var(--transition-smooth);
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Link zapomniałeś hasła */
.forgot-password-link {
    color: var(--neon-cyan);
    font-size: 0.825rem;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.forgot-password-link:hover {
    color: #ffffff;
    text-shadow: 0 0 8px rgba(0, 242, 254, 0.6);
}

/* Wrapper pola input (ikona + pole + neonowa linia) */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition-smooth);
}

/* Ikona w inputach */
.input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    pointer-events: none;
}

/* Stylizacja pól tekstowych */
.input-wrapper input {
    width: 100%;
    padding: 16px 16px 16px 52px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 400;
    transition: var(--transition-smooth);
}

/* Placki / Placeholdery */
.input-wrapper input::placeholder {
    color: var(--text-muted);
}

/* Zmień padding dla hasła, aby zmieścić przycisk toggle */
#password-input {
    padding-right: 52px;
}

/* Przyciski toggle hasła */
.toggle-password {
    position: absolute;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    padding: 0;
}

.toggle-password:hover {
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   Stany Focus i Walidacja
   ========================================================================== */

/* Specjalny focus dla loginu (Cyan Glow) */
.input-group:focus-within label[for="username-input"] {
    color: var(--neon-cyan);
    text-shadow: 0 0 8px rgba(0, 242, 254, 0.4);
}

.input-group:focus-within #username-input {
    color: #ffffff;
}

.input-group:focus-within #username-input ~ .input-icon,
.input-group:focus-within #username-input + .input-icon {
    /* CSS Selector fallback */
}
.input-group:focus-within:has(#username-input) .input-icon {
    color: var(--neon-cyan);
    filter: drop-shadow(0 0 4px rgba(0, 242, 254, 0.6));
}
.input-group:focus-within:has(#username-input) .input-wrapper {
    border-color: var(--neon-cyan);
    background: rgba(0, 242, 254, 0.02);
    box-shadow: 
        0 0 0 1px var(--neon-cyan),
        0 0 15px rgba(0, 242, 254, 0.15);
}

/* Specjalny focus dla hasła (Magenta Glow) */
.input-group:focus-within label[for="password-input"] {
    color: var(--neon-magenta);
    text-shadow: 0 0 8px rgba(255, 8, 68, 0.4);
}

.input-group:focus-within:has(#password-input) .input-icon {
    color: var(--neon-magenta);
    filter: drop-shadow(0 0 4px rgba(255, 8, 68, 0.6));
}
.input-group:focus-within:has(#password-input) .input-wrapper {
    border-color: var(--neon-magenta);
    background: rgba(255, 8, 68, 0.02);
    box-shadow: 
        0 0 0 1px var(--neon-magenta),
        0 0 15px rgba(255, 8, 68, 0.15);
}

/* Błędy walidacji */
.input-group.invalid .input-wrapper {
    border-color: var(--neon-magenta) !important;
    background: rgba(255, 8, 68, 0.05) !important;
    box-shadow: 
        0 0 0 1px var(--neon-magenta),
        0 0 10px rgba(255, 8, 68, 0.2) !important;
}

.error-message {
    color: var(--neon-magenta);
    font-size: 0.775rem;
    font-weight: 500;
    margin-top: 6px;
    height: 16px;
    opacity: 0;
    transform: translateY(-4px);
    transition: var(--transition-bounce);
}

.input-group.invalid .error-message {
    opacity: 1;
    transform: translateY(0);
}

/* Autofill styling w przeglądarkach */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary) !important;
    -webkit-box-shadow: 0 0 0px 1000px rgba(13, 13, 21, 0.9) inset !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* ==========================================================================
   Zapamiętaj Mnie (Custom Checkbox)
   ========================================================================== */
.form-actions {
    margin-top: -6px;
    margin-bottom: 32px;
}

.remember-me-checkbox {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: var(--transition-smooth);
}

.remember-me-checkbox:hover {
    color: var(--text-primary);
}

.remember-me-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.custom-checkbox {
    height: 20px;
    width: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    margin-right: 12px;
    position: relative;
    transition: var(--transition-smooth);
}

/* Hover na checkbox */
.remember-me-checkbox:hover .custom-checkbox {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

/* Stan zaznaczony checkboxa (Glow) */
.remember-me-checkbox input:checked ~ .custom-checkbox {
    background: var(--grad-primary);
    border-color: transparent;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.4);
}

/* Ptak w checkboxie */
.custom-checkbox::after {
    content: "";
    position: absolute;
    display: none;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.remember-me-checkbox input:checked ~ .custom-checkbox::after {
    display: block;
}

/* ==========================================================================
   Przycisk Logowania (Neon Submit)
   ========================================================================== */
.submit-button {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    background: var(--grad-primary);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(255, 8, 68, 0.25), 0 4px 15px rgba(0, 242, 254, 0.2);
    transition: var(--transition-bounce);
}

.submit-button:hover {
    transform: translateY(-2px);
    background: var(--grad-button-hover);
    box-shadow: 
        0 6px 20px rgba(255, 8, 68, 0.35), 
        0 6px 20px rgba(0, 242, 254, 0.3),
        0 0 12px rgba(0, 242, 254, 0.3) inset;
}

.submit-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(0, 242, 254, 0.2);
}

/* Efekt świetlistego błysku przy naciśnięciu / najechaniu */
.submit-button::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.25),
        transparent
    );
    transition: 0.5s;
}

.submit-button:hover::after {
    left: 100%;
}

.btn-text {
    transition: var(--transition-smooth);
}

/* Spinner ładowania w przycisku */
.btn-loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
    position: absolute;
}

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

/* ==========================================================================
   Stopka Panelu (Rejestracja)
   ========================================================================== */
.login-footer {
    margin-top: 32px;
    text-align: center;
}

.login-footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.signup-link {
    color: var(--neon-magenta);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.signup-link:hover {
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 8, 68, 0.6);
}

/* ==========================================================================
   Powiadomienia Toast (Sukces)
   ========================================================================== */
.toast-notification {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 13, 21, 0.85);
    border: 1px solid var(--neon-green);
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(0, 255, 135, 0.2);
    border-radius: 16px;
    padding: 16px 24px;
    z-index: 100;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-bounce);
}

.toast-notification.show {
    bottom: 32px;
    opacity: 1;
    visibility: visible;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toast-icon {
    color: var(--neon-green);
    filter: drop-shadow(0 0 4px rgba(0, 255, 135, 0.6));
    animation: pulseIcon 2s infinite;
}

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

.toast-text {
    display: flex;
    flex-direction: column;
}

.toast-title {
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
}

.toast-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ==========================================================================
   Responsywność i Media Queries
   ========================================================================== */
@media (max-width: 480px) {
    .login-card {
        padding: 32px 20px 24px 20px;
        border-radius: 20px;
    }
    
    .login-header h1 {
        font-size: 1.75rem;
    }
    
    .login-container {
        padding: 16px;
    }
}

/* Redukcja ruchu (Ułatwienia dostępu) */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-delay: 0s !important;
        animation-duration: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0s !important;
        scroll-behavior: auto !important;
    }
}
