/**
 * TDEE Calculator - Styles
 * Cleanfit - อาหารคลีนเพื่อสุขภาพ
 */

/* ===== Base Styles ===== */
* {
    font-family: 'Sarabun', sans-serif;
}

/* ===== Gradient Backgrounds ===== */
.gradient-bg {
    background: linear-gradient(135deg, #166534 0%, #22c55e 50%, #4ade80 100%);
}

/* ===== Card Styles ===== */
.card-shadow {
    box-shadow: 0 4px 6px -1px rgba(255, 255, 255, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.result-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

/* ===== Form Inputs ===== */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* ===== Radio Buttons (Green Theme) ===== */
input[type="radio"] {
    accent-color: #22c55e;
}

input[type="radio"]:checked {
    background-color: #22c55e;
    border-color: #22c55e;
}

/* ===== Checkboxes (Green Theme) ===== */
input[type="checkbox"] {
    accent-color: #22c55e;
}

/* ===== Details/Accordion ===== */
details[open] .details-chevron {
    transform: rotate(90deg);
}

details summary::-webkit-details-marker {
    display: none;
}

/* ===== Animations ===== */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* ===== Modal Overlay ===== */
.modal-overlay {
    backdrop-filter: blur(4px);
}

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ===== Phase Colors for Chart ===== */
.phase-1 { color: #22c55e; }
.phase-2 { color: #3b82f6; }
.phase-3 { color: #8b5cf6; }
.phase-4 { color: #f59e0b; }
.phase-5 { color: #ec4899; }
.phase-6 { color: #14b8a6; }

/* ===== Loading States ===== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 640px) {
    .card-shadow {
        padding: 1rem;
    }
}

/* ===== Mobile Optimizations ===== */
@media (max-width: 768px) {
    /* Larger touch targets for mobile */
    input, select, button {
        min-height: 48px;
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }
    
    /* Better spacing on mobile */
    main {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Larger radio/checkbox targets */
    label.flex.items-center {
        min-height: 52px;
    }
    
    /* Form inputs more touch-friendly */
    input[type="number"],
    input[type="email"],
    select {
        padding: 14px 16px;
        font-size: 16px;
    }
    
    /* Bigger buttons on mobile */
    button[type="submit"],
    button[type="button"] {
        padding: 16px 20px;
        font-size: 16px;
    }
    
    /* Modal improvements for mobile */
    .fixed.inset-0 {
        padding: 0.5rem;
    }
    
    /* Better result cards on mobile */
    .result-card {
        padding: 12px;
    }
    
    .result-card p.text-2xl {
        font-size: 1.5rem;
    }
    
    /* Chart height on mobile */
    .relative.h-64 {
        height: 250px;
    }
}

/* ===== Small Mobile (< 375px) ===== */
@media (max-width: 375px) {
    /* Even more compact on very small screens */
    .grid-cols-2 {
        grid-template-columns: 1fr;
    }
    
    /* Smaller header on tiny screens */
    header h1 {
        font-size: 1.25rem;
    }
    
    /* Stack buttons vertically */
    .flex.gap-6 {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* ===== Touch Device Optimizations ===== */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects for touch devices */
    button:hover,
    a:hover {
        opacity: 1;
    }
    
    /* Add active state for touch */
    button:active {
        transform: scale(0.98);
    }
    
    /* Bigger tap areas */
    details summary {
        padding: 16px;
    }
}

/* ===== iOS Specific Fixes ===== */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS input styling */
    input, select, textarea {
        -webkit-appearance: none;
        border-radius: 8px;
    }
    
    /* Fix for iOS button styling */
    button {
        -webkit-appearance: none;
    }
}

/* ===== Bounce Animation for CTA ===== */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.animate-bounce {
    animation: bounce 2s ease-in-out infinite;
}

/* ===== Pulse Animation for urgency ===== */
@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(34, 197, 94, 0);
    }
}

.pulse-green {
    animation: pulse-green 2s infinite;
}

/* ===== Safe Area for notched devices ===== */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* ===== iOS/Mobile Performance Optimizations ===== */
/* GPU Acceleration for smooth scrolling */
html {
    -webkit-overflow-scrolling: touch;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Hardware acceleration for animations */
.animate-spin,
.animate-bounce,
.pulse-green,
.transition-all,
.transition-colors,
.transition-transform {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .animate-spin,
    .animate-bounce,
    .pulse-green {
        animation: none !important;
    }
}

/* Optimize backdrop-blur on mobile (can cause lag) */
@media (max-width: 768px) {
    .backdrop-blur-sm {
        backdrop-filter: none;
        background-color: rgba(0, 0, 0, 0.6);
    }
}

/* Smooth scrolling container */
main,
.overflow-auto,
.overflow-y-auto {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

