:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --accent: #8b5cf6;
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-white: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --font-thai: 'Kanit', sans-serif;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
    font-family: var(--font-thai);
    color: var(--text-white);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 4rem;
    animation: fadeInDown 1s ease-out;
}

h1 {
    font-size: 3rem;
    background: linear-gradient(to right, #818cf8, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.auth-box {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.login-btn {
    background: var(--primary);
    border: none;
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    font-size: 0.9rem;
}

.login-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-white);
}

.logout-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.4rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.logout-btn:hover {
    background: var(--danger);
    color: white;
}

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }
}

.calculator-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    animation: fadeInLeft 1s ease-out;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-weight: 300;
}

.input-style {
    width: 100%;
    padding: 1rem 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.input-style:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.gender-toggle {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.gender-btn {
    flex: 1;
    padding: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.gender-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.calculate-btn {
    width: 100%;
    padding: 1.2rem;
    background: linear-gradient(to right, var(--primary), var(--accent));
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 1rem;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.5);
}

.calculate-btn:active {
    transform: translateY(0);
}

.results-section {
    position: sticky;
    top: 2rem;
    animation: fadeInRight 1s ease-out;
}

.result-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.result-value {
    text-align: center;
    margin-bottom: 2rem;
}

.result-number {
    font-size: 4rem;
    font-weight: 700;
    display: block;
    line-height: 1;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.result-label {
    color: var(--text-muted);
    font-size: 1.2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
}

.stat-val {
    display: block;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.stat-lab {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Animations */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

.floating-shapes {
    position: fixed;
    z-index: -1;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    pointer-events: none;
}

.shape {
    position: absolute;
    filter: blur(80px);
    border-radius: 50%;
    opacity: 0.4;
    animation: pulse 10s infinite alternate;
}

.shape-1 { width: 400px; height: 400px; background: var(--primary); top: -100px; left: -100px; }
.shape-2 { width: 300px; height: 300px; background: var(--secondary); bottom: -50px; right: -50px; }
.shape-3 { width: 250px; height: 250px; background: var(--accent); top: 40%; right: 10%; }

@keyframes pulse {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.2) translate(50px, 30px); }
}

/* History Section */
.history-section {
    margin-top: 4rem;
    animation: fadeInUp 1s ease-out;
}

.history-title {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.history-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.history-item:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-gender {
    font-weight: 600;
    color: var(--accent);
}

.history-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.h-stat {
    display: flex;
    flex-direction: column;
}

.h-stat-val {
    font-weight: 600;
}

.h-stat-lab {
    font-size: 0.75rem;
    color: var(--text-muted);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* PWA Styles */
.pwa-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

.pwa-install-btn {
    background: linear-gradient(to right, #6366f1, #ec4899);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    font-family: var(--font-thai);
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: all 0.3s ease;
    animation: bounceIn 1s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.pwa-install-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.5);
}

@keyframes bounceIn {
    0% { transform: translate(-50%, 100px) scale(0.5); opacity: 0; }
    70% { transform: translate(-50%, -10px) scale(1.1); }
    100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}
