/* === ZMIENNE CSS === */
:root {
    --primary: #20314b;
    --primary-dark: #1a2738;
    --primary-light: #2a3f5a;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    /* Kolory neutralne */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    /* Gradienenty - ustawione na dark mode */
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    --card-gradient: linear-gradient(145deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.9) 100%);
    --button-gradient: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    
    /* Cienie */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    
    /* Blur i szkło */
    --blur-sm: blur(4px);
    --blur-md: blur(8px);
    --blur-lg: blur(16px);
    
    /* Radiusy */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    
    /* Timing functions */
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* === RESET === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === BODY === */
body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height dla mobile */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    position: relative;
    overflow-x: hidden;
    /* Zapobieganie zoom na iOS przy focus input */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Subtelne animated background patterns */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(32, 49, 75, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(2rem, -1rem) rotate(1deg); }
    66% { transform: translate(-1rem, 1rem) rotate(-1deg); }
}

/* === CONTAINER === */
.login-container {
    background: var(--card-gradient);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    backdrop-filter: var(--blur-lg);
    width: 100%;
    max-width: 24rem;
    padding: 3rem 2rem;
    position: relative;
    animation: slideUp 0.8s var(--ease-spring);
}

.login-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: var(--radius-2xl);
    z-index: -1;
}

/* Subtle top border glow */
.login-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 1rem;
    right: 1rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    border-radius: 1px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(2rem) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* === LOGO === */
.logo {
    text-align: center;
    margin-bottom: 2.5rem;
    position: relative;
}

.logo img {
    height: 4rem;
    width: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.07));
    transition: all 0.3s var(--ease-out);
}

/* === FORM === */


/* === FORM GROUPS === */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-group:last-of-type {
    margin-bottom: 2rem;
}
#username {
    text-transform: uppercase;
}

/* === LABELS === */
label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-300);
    margin-bottom: 0.5rem;
    transition: color 0.2s var(--ease-out);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* === INPUTS === */
input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    transition: all 0.2s var(--ease-out);
    font-family: inherit;
    outline: none;
    box-shadow: var(--shadow-sm);
    /* Optymalizacje mobile */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Zapobieganie zoom na iOS */
    font-size: max(16px, 1rem);
}

input::placeholder {
    color: var(--gray-500);
    opacity: 1;
}

input:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(32, 49, 75, 0.1);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

input:focus + label {
    color: var(--primary);
}

/* Input icons */
.form-group {
    position: relative;
}

.form-group[data-field="username"]::before {
    content: '👤';
    position: absolute;
    right: 1rem;
    top: 2.25rem;
    font-size: 1rem;
    color: var(--gray-400);
    pointer-events: none;
    transition: all 0.2s var(--ease-out);
    z-index: 1;
}

.form-group[data-field="password"]::before {
    content: '🔒';
    position: absolute;
    right: 1rem;
    top: 2.25rem;
    font-size: 1rem;
    color: var(--gray-400);
    pointer-events: none;
    transition: all 0.2s var(--ease-out);
    z-index: 1;
}

input:focus ~ ::before {
    color: var(--primary);
}

/* === BUTTON === */
button {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--gray-700); /* zmienione z #1a2738 */
    background: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    box-shadow: var(--shadow-md);
    font-family: inherit;
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

/* Tekst wewnątrz przycisku zawsze nad pseudoelementem */
button span {
    position: relative;
    z-index: 1;
}

/* Pseudoelement gradientu hover */
button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    opacity: 0;
    transition: opacity 0.2s var(--ease-out);
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

/* Pokazujemy gradient przy hover */
button:hover::before {
    opacity: 1;
}

/* Efekty hover przycisku */
button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Kliknięcie */
button:active {
    transform: translateY(0);
    box-shadow: var(--shadow);
}

/* Wyłączony przycisk */
button:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-sm);
    opacity: 0.6;
}

button:disabled:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* Loading state */
button.loading {
    pointer-events: none;
    position: relative;
}

button.loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animacja kółka dla loading */
@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}


/* === ERROR MESSAGE === */
.error {
    background: linear-gradient(135deg, var(--error) 0%, #dc2626 100%);
    color: var(--white);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: none;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-md);
    animation: errorSlide 0.3s var(--ease-out);
}

.error.show {
    display: block;
    animation: errorShake 0.6s var(--ease-out);
}

/* .error::before {
    content: '⚠️';
    margin-right: 0.5rem;
} */

@keyframes errorSlide {
    from {
        opacity: 0;
        transform: translateY(-0.5rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-0.25rem); }
    20%, 40%, 60%, 80% { transform: translateX(0.25rem); }
}

/* === RESPONSYWNOŚĆ === */
@media (max-width: 640px) {
    body {
        padding: 0.5rem;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    .login-container {
        padding: 2.5rem 1.5rem;
        max-width: 100%;
        width: 100%;
        margin: 0;
        min-height: auto;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    }
    
    .logo {
        margin-bottom: 2rem;
    }
    
    .logo img {
        height: 4rem;
    }
    
    input, button {
        padding: 1rem;
        font-size: 1rem;
        border-radius: var(--radius-lg);
    }
    
    input {
        min-height: 56px;
        box-sizing: border-box;
    }
    
    button {
        min-height: 56px;
        font-weight: 700;
    }
    
    .form-group {
        margin-bottom: 1.5rem;
    }
    
    .error {
        margin-bottom: 1.25rem;
        padding: 1rem;
        font-size: 0.9375rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.25rem;
    }
    
    .login-container {
        padding: 2rem 1.25rem;
        width: calc(100% - 0.5rem);
        margin: 0 auto;
    }
    
    .logo {
        margin-bottom: 1.75rem;
    }
    
    .logo img {
        height: 3.5rem;
    }
    
    label {
        font-size: 0.875rem;
        margin-bottom: 0.75rem;
    }
    
    input, button {
        padding: 1rem;
        font-size: 1rem;
        min-height: 52px;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .error {
        font-size: 0.875rem;
        padding: 0.875rem;
    }
}

/* === HIGH DPI SCREENS === */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    body::before {
        animation: none;
    }
    
    .login-container {
        animation: none;
    }
    
    button:hover {
        transform: none;
    }
    
    input:focus {
        transform: none;
    }
}

/* Focus rings dla accessibility */
/* Optymalizacje dla urządzeń dotykowych */
@media (any-hover: none) and (any-pointer: coarse) {
    button:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }
    
    input:hover {
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    /* Lepsze target sizes dla touch */
    input, button {
        min-height: 48px;
    }
    
    /* Zapobieganie zoom na iOS */
    input {
        font-size: 16px;
    }
    
    /* Wygładzone przewijanie */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* === PRINT STYLES === */
@media print {
    body {
        background: white;
    }
    
    .login-container {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* === CUSTOM FOCUS INDICATORS === */
input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 2px;
}