/* Enhanced Responsive Styles for KU OPAS - Updated Version */

/* Modern Design System */
:root {
    --primary-green: #16a34a;
    --primary-blue: #0ea5e9;
    --primary-purple: #7c3aed;
    --accent-orange: #f59e0b;
    --dark-bg: #0f172a;
    --dark-surface: #1e293b;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    /* Dynamic viewport height */
    --vh: 1vh;
    
    /* Responsive spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
}

/* Mobile-first responsive typography */
html {
    font-size: 14px;
    scroll-behavior: smooth;
}

@media (min-width: 475px) {
    html { font-size: 15px; }
}

@media (min-width: 640px) {
    html { font-size: 16px; }
}

@media (min-width: 1024px) {
    html { font-size: 17px; }
}

@media (min-width: 1280px) {
    html { font-size: 18px; }
}

/* Enhanced Body Styles */
body {
    font-family: 'Sarabun', sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--dark-surface) 100%);
    color: var(--text-primary);
    line-height: 1.6;
    letter-spacing: 0.025em;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
}

/* Mobile device detection class */
.mobile-device {
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* Custom breakpoint utilities */
@media (min-width: 475px) {
    .xs\:block { display: block; }
    .xs\:hidden { display: none; }
    .xs\:flex { display: flex; }
    .xs\:grid { display: grid; }
    .xs\:text-sm { font-size: 0.875rem; }
    .xs\:text-base { font-size: 1rem; }
    .xs\:px-4 { padding-left: 1rem; padding-right: 1rem; }
    .xs\:py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
}

/* Enhanced Glass morphism effects */
.glass-morphism {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

/* Mobile-optimized glass effects */
@media (max-width: 768px) {
    .glass-morphism {
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    
    .glass-card {
        background: rgba(255, 255, 255, 0.08);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
}

/* Enhanced Button Styles with Responsive Design */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-purple));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* Enhanced KU ALL LOGIN Button */
.btn-secondary {
    position: relative;
    background: linear-gradient(135deg, var(--primary-green) 0%, #059669 50%, var(--primary-blue) 100%);
    border: none;
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(22, 163, 74, 0.3);
    overflow: hidden;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-secondary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.btn-secondary:hover::before {
    left: 100%;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #059669 0%, var(--primary-green) 50%, var(--primary-blue) 100%);
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(22, 163, 74, 0.4);
}

.btn-secondary:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(22, 163, 74, 0.3);
}

/* Mobile responsive buttons */
@media (max-width: 640px) {
    .btn-primary,
    .btn-ghost,
    .btn-secondary {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        border-radius: 0.5rem;
        width: 100%;
        justify-content: center;
    }
    
    .btn-primary svg,
    .btn-ghost svg,
    .btn-secondary svg {
        width: 1rem;
        height: 1rem;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .btn-primary,
    .btn-ghost,
    .btn-secondary {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
}

/* Enhanced Navigation */
.nav-link {
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-blue);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::before {
    width: 80%;
}

/* Enhanced Floating Elements */
.floating-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

.floating-circle {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--primary-blue), var(--primary-purple));
    opacity: 0.1;
    animation: float 15s ease-in-out infinite;
}

.floating-circle:nth-child(1) {
    width: 80px;
    height: 80px;
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.floating-circle:nth-child(2) {
    width: 120px;
    height: 120px;
    top: 60%;
    right: 15%;
    animation-delay: -5s;
}

.floating-circle:nth-child(3) {
    width: 60px;
    height: 60px;
    bottom: 30%;
    left: 60%;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { 
        transform: translateY(0px) rotate(0deg);
        opacity: 0.1;
    }
    50% { 
        transform: translateY(-20px) rotate(180deg);
        opacity: 0.15;
    }
}

/* Mobile optimized floating elements */
@media (max-width: 768px) {
    .floating-circle {
        opacity: 0.05;
    }
    
    .floating-circle:nth-child(1) {
        width: 60px;
        height: 60px;
    }
    
    .floating-circle:nth-child(2) {
        width: 80px;
        height: 80px;
    }
    
    .floating-circle:nth-child(3) {
        width: 40px;
        height: 40px;
    }
}

/* Gradient overlay */
.gradient-overlay {
    background: linear-gradient(135deg, 
        rgba(22, 163, 74, 0.1) 0%, 
        rgba(14, 165, 233, 0.1) 35%, 
        rgba(124, 58, 237, 0.1) 70%, 
        rgba(245, 158, 11, 0.1) 100%);
}

/* Enhanced Logo */
.logo-glow {
    filter: drop-shadow(0 0 25px rgba(14, 165, 233, 0.6)) drop-shadow(0 0 50px rgba(14, 165, 233, 0.3));
    transition: filter 0.3s ease;
}

.logo-glow:hover {
    filter: drop-shadow(0 0 35px rgba(14, 165, 233, 0.8)) drop-shadow(0 0 70px rgba(14, 165, 233, 0.4));
}

/* KU Icon Animation */
.ku-icon-animate {
    transition: all 0.3s ease;
}

.btn-secondary:hover .ku-icon-animate {
    transform: rotate(360deg) scale(1.1);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

/* Pulse Effect for KU Button */
.ku-pulse {
    animation: ku-pulse 2s infinite;
}

@keyframes ku-pulse {
    0% {
        box-shadow: 0 4px 15px rgba(22, 163, 74, 0.3);
    }
    50% {
        box-shadow: 0 4px 15px rgba(22, 163, 74, 0.5), 0 0 0 8px rgba(22, 163, 74, 0.1);
    }
    100% {
        box-shadow: 0 4px 15px rgba(22, 163, 74, 0.3);
    }
}

/* Security Badge */
.security-badge {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

.btn-secondary:hover .security-badge {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* Loading Animation */
.ku-loading {
    animation: ku-loading 1s linear infinite;
}

@keyframes ku-loading {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced Footer */
.footer-section {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-link {
    color: var(--text-muted);
    transition: color 0.3s ease;
    text-decoration: none;
}

.footer-link:hover {
    color: var(--text-primary);
}

/* Status indicator */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

/* Enhanced Form Styles */
input, textarea, select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    color: white;
    padding: 0.75rem;
    padding-left: 2.5rem;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 1rem;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

input::placeholder, textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Mobile form optimizations */
@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 1rem;
        padding-left: 2.5rem;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .glass-card:hover {
        transform: none;
        background: rgba(255, 255, 255, 0.1);
    }
    
    .btn-primary:hover,
    .btn-ghost:hover,
    .btn-secondary:hover {
        transform: none;
    }
    
    .glass-card:active {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.15);
    }
    
    .btn-primary:active,
    .btn-ghost:active,
    .btn-secondary:active {
        transform: scale(0.95);
    }
}

/* Mobile menu animations */
#mobile-menu {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    max-height: 400px;
    overflow: hidden;
}

#mobile-menu.hidden {
    opacity: 0;
    max-height: 0;
    pointer-events: none;
}

/* Header scroll behavior */
header {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-hidden {
    transform: translateY(-100%);
}

/* Safe area support for devices with notches */
@supports (padding: max(0px)) {
    .safe-top {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .safe-bottom {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .safe-left {
        padding-left: max(1rem, env(safe-area-inset-left));
    }
    
    .safe-right {
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* Animation on scroll */
.animate-in {
    animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
    transform: translateY(30px);
}

@keyframes slideInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Improved text legibility */
@media (max-width: 640px) {
    body {
        line-height: 1.7;
    }
    
    h1, h2, h3, h4, h5, h6 {
        line-height: 1.3;
    }
    
    p {
        margin-bottom: 1rem;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.3);
}

::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 233, 0.5);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(14, 165, 233, 0.7);
}

/* Focus styles for accessibility */
.btn-primary:focus,
.btn-ghost:focus,
.btn-secondary:focus,
input:focus,
textarea:focus,
select:focus,
a:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Skip link 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: 0;
}

.focus\:not-sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0.5rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* PWA mode adjustments */
.pwa-mode {
    --vh: 1vh;
}

.pwa-mode body {
    min-height: calc(var(--vh) * 100);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .floating-circle {
        animation: none;
    }
    
    .ku-pulse {
        animation: none;
    }
}

/* Dark mode optimizations (if needed) */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f8fafc;
        --text-secondary: #e2e8f0;
        --text-muted: #94a3b8;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .glass-morphism,
    .glass-card {
        background: rgba(255, 255, 255, 0.2);
        border: 2px solid rgba(255, 255, 255, 0.4);
    }
    
    .btn-primary,
    .btn-secondary {
        border: 2px solid white;
    }
}

/* Performance optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Optimize images for retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-glow {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}