/**
 * Login Page Styles - Keuangan Keluarga
 * Extracted from inline styles for better performance and maintainability
 */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

/* Ensure proper centering in landscape */
body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* Animated Gradient Background */
body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    position: relative;
    min-height: 100vh;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Dark mode background */
body.dark {
    background: linear-gradient(135deg, #1e3a8a 0%, #312e81 25%, #4c1d95 50%, #1e40af 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

/* Floating particles */
.particle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    animation: float 20s ease-in-out infinite, fadeInParticle 1s ease-in forwards;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) translateX(0) rotate(0deg);
    }
    25% {
        transform: translateY(-100px) translateX(50px) rotate(90deg);
    }
    50% {
        transform: translateY(-50px) translateX(-50px) rotate(180deg);
    }
    75% {
        transform: translateY(-150px) translateX(100px) rotate(270deg);
    }
}

@keyframes fadeInParticle {
    to { opacity: 0.05; }
}

/* Card fade-in slide-up animation */
.login-card {
    animation: slideUpFadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpFadeIn {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Logo pulse animation */
.logo-pulse {
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

/* Glassmorphism effect */
.glass {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
}

body.dark .glass {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* Smooth input transitions */
.input-wrapper {
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-field {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-field:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.15);
}

/* Button gradient animation */
.btn-gradient {
    background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
    background-size: 200% 200%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: gradientSlide 3s ease infinite;
}

@keyframes gradientSlide {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.btn-gradient:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(14, 165, 233, 0.35);
}

.btn-gradient:active {
    transform: translateY(-1px);
}

/* Dark mode toggle */
.toggle-checkbox:checked {
    background-color: #0ea5e9;
    border-color: #0ea5e9;
}

.toggle-checkbox:checked + .toggle-label {
    transform: translateX(100%);
}

/* Smooth transitions */
* {
    transition-property: color, background-color, border-color, opacity;
    transition-duration: 300ms;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide scrollbar but keep functionality */
body::-webkit-scrollbar {
    width: 8px;
}

body::-webkit-scrollbar-track {
    background: transparent;
}

body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

body.dark::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

/* Skip to content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #0ea5e9;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 8px 0;
    z-index: 100;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
}

/* Password strength indicator */
.strength-bar {
    height: 4px;
    border-radius: 2px;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.strength-weak { 
    width: 33%; 
    background: #ef4444; 
}

.strength-medium { 
    width: 66%; 
    background: #f59e0b; 
}

.strength-strong { 
    width: 100%; 
    background: #10b981; 
}

/* Rate limit indicator */
.rate-limit-warning {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Screen reader only - for accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* CRITICAL: Force text colors - explicit for both modes */

/* Title */
h1.text-gray-900, h1 {
    color: #111827 !important;
}

body.dark h1.text-gray-900,
body.dark h1 {
    color: #ffffff !important;
}

/* Tagline */
p.text-gray-700 {
    color: #374151 !important;
}

body.dark p.text-gray-700,
body.dark .text-gray-300 {
    color: #d1d5db !important;
}

/* Labels */
label.text-gray-900, label {
    color: #111827 !important;
}

body.dark label.text-gray-900,
body.dark label {
    color: #e5e7eb !important;
}

/* Checkbox label & footer */
span.text-gray-900 {
    color: #111827 !important;
}

body.dark span,
body.dark .text-gray-300 {
    color: #d1d5db !important;
}

/* Footer */
.text-gray-600 {
    color: #4b5563 !important;
}

body.dark .text-gray-600,
body.dark .text-slate-400 {
    color: #94a3b8 !important;
}

input {
    background-color: #f9fafb !important;
    color: #111827 !important;
    border-color: #d1d5db !important;
}

body.dark input {
    background-color: #1e293b !important;
    color: #ffffff !important;
    border-color: #475569 !important;
}

/* Specific overrides */
body.dark .text-gray-600 {
    color: #9ca3af !important;
}

body.dark .text-slate-400 {
    color: #94a3b8 !important;
}

body.dark .text-slate-300 {
    color: #cbd5e1 !important;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Mobile */
@media (max-width: 640px) {
    .login-card {
        margin: 1rem;
        padding: 2rem 1.5rem !important;
    }
}

/* Tablet landscape optimization */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .login-card {
        max-width: 450px !important;
        padding: 2rem 2.5rem !important;
        margin: 1rem auto !important;
    }
    
    .particle {
        font-size: 2.5rem !important;
    }
    
    /* Compact spacing for landscape */
    .login-card .mb-8 {
        margin-bottom: 1.5rem !important;
    }
    
    .login-card .space-y-5 > * + * {
        margin-top: 1rem !important;
    }
    
    /* Smaller logo for landscape */
    .logo-pulse {
        width: 4rem !important;
        height: 4rem !important;
    }
    
    .logo-pulse span {
        font-size: 2rem !important;
    }
    
    /* Compact title */
    .login-card h1 {
        font-size: 1.75rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .login-card p {
        font-size: 0.875rem !important;
    }
    
    /* Compact inputs */
    .input-field {
        padding-top: 0.625rem !important;
        padding-bottom: 0.625rem !important;
    }
    
    /* Compact button */
    .btn-gradient {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}

/* Phone landscape - even more compact */
@media (max-width: 767px) and (orientation: landscape) {
    body {
        padding: 0.5rem !important;
    }
    
    .login-card {
        max-width: 100% !important;
        width: 100% !important;
        padding: 1.5rem !important;
        margin: 0.5rem auto !important;
    }
    
    /* Very compact spacing */
    .login-card .mb-8 {
        margin-bottom: 1rem !important;
    }
    
    .login-card .space-y-5 > * + * {
        margin-top: 0.75rem !important;
    }
    
    /* Smaller logo */
    .logo-pulse {
        width: 3.5rem !important;
        height: 3.5rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .logo-pulse span {
        font-size: 1.75rem !important;
    }
    
    /* Compact title */
    .login-card h1 {
        font-size: 1.5rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    .login-card p {
        font-size: 0.75rem !important;
    }
    
    /* Compact inputs */
    .input-field {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
        font-size: 0.875rem !important;
    }
    
    label {
        font-size: 0.75rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    /* Compact button */
    .btn-gradient {
        padding-top: 0.625rem !important;
        padding-bottom: 0.625rem !important;
        font-size: 0.875rem !important;
        margin-top: 1rem !important;
    }
    
    /* Hide particles on phone landscape */
    .particle {
        display: none !important;
    }
    
    /* Compact footer */
    .login-card p:last-child {
        margin-top: 1rem !important;
        font-size: 0.625rem !important;
    }
    
    /* Hide dark mode toggle on small landscape */
    #darkModeToggle {
        transform: scale(0.8);
        top: 0.5rem !important;
        right: 0.5rem !important;
    }
    
    /* Hide install button on small landscape */
    #pwa-install-btn {
        top: 0.5rem !important;
        right: 3.5rem !important;
        transform: scale(0.8);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .glass {
        background: rgba(255, 255, 255, 1) !important;
        border: 2px solid #000 !important;
    }
    body.dark .glass {
        background: rgba(0, 0, 0, 1) !important;
        border: 2px solid #fff !important;
    }
}

/* Landscape scroll optimization */
@media (orientation: landscape) and (max-height: 600px) {
    body {
        overflow-y: auto;
        align-items: flex-start;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    .login-card {
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }
}

/* Very short landscape screens */
@media (orientation: landscape) and (max-height: 450px) {
    body {
        padding: 0.5rem;
    }
    
    .login-card {
        transform: scale(0.9);
        transform-origin: center top;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
