:root {
    --bg-dark: #0f172a;
    --bg-darker: #060d1a;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --accent: #3b82f6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(59, 130, 246, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --card-optimal-bg: rgba(139, 92, 246, 0.15);
    --card-optimal-border: rgba(139, 92, 246, 0.4);
    
    --font-heading: 'Inter', 'Noto Sans Thai', sans-serif;
    --font-body: 'Noto Sans Thai', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-darker);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* Background Animation */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(to bottom, #020617 0%, #0f172a 100%);
}

.stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent url('data:image/svg+xml;utf8,<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg"><circle cx="20" cy="20" r="1" fill="white" opacity="0.3"/><circle cx="80" cy="90" r="1" fill="white" opacity="0.5"/><circle cx="150" cy="40" r="1" fill="white" opacity="0.2"/><circle cx="180" cy="150" r="1" fill="white" opacity="0.6"/><circle cx="40" cy="180" r="1.5" fill="white" opacity="0.4"/><circle cx="110" cy="120" r="1" fill="white" opacity="0.3"/></svg>') repeat;
}

.twinkling {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    background: transparent url('data:image/svg+xml;utf8,<svg width="400" height="400" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="1.5" fill="white" opacity="0.8"/><circle cx="250" cy="150" r="2" fill="white" opacity="0.9"/><circle cx="350" cy="350" r="1" fill="white" opacity="0.7"/><circle cx="150" cy="280" r="1.5" fill="white" opacity="0.6"/></svg>') repeat;
    animation: move-twink-back 100s linear infinite;
    opacity: 0.5;
}

@keyframes move-twink-back {
    from {transform: translate(0, 0);}
    to {transform: translate(-50%, -50%);}
}

/* Typography & Layout */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.hero {
    text-align: center;
    padding: 60px 0 40px;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #a78bfa 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Glassmorphism Classes */
.glass-block {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 20px;
}

/* Calculator Section */
.calculator-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 50px;
}

/* Tabs */
.tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 5px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    padding: 12px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Inputs & Buttons */
.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
}

.input-group label {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-main);
}

.time-input {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 12px;
    text-align: center;
    width: 220px;
    outline: none;
    transition: border-color 0.3s;
}

.time-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* Time input inner elements styling for webkit */
.time-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.time-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 15px 30px;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
    background: linear-gradient(135deg, var(--primary-hover) 0%, #4f46e5 100%);
}

.primary-btn:active {
    transform: translateY(1px);
}

.sleep-now-wrapper {
    text-align: center;
}

.sleep-now-text {
    font-size: 1.1rem;
    margin-bottom: 25px;
    color: var(--text-main);
}

.zzz-btn {
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.zzz-btn:hover {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.5);
}

/* Results Area */
.results-area {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--glass-border);
}

.results-area.hidden {
    display: none;
}

.results-title {
    font-size: 1.3rem;
    margin-bottom: 5px;
    text-align: center;
}

.results-desc {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 25px;
    font-size: 0.95rem;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.result-card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px 10px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    background: rgba(30, 41, 59, 0.8);
}

.card-time {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 5px;
}

.card-cycles {
    font-size: 0.9rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 3px;
}

.card-duration {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.result-card.optimal {
    background: var(--card-optimal-bg);
    border-color: var(--card-optimal-border);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
    position: relative;
    overflow: hidden;
}

.result-card.optimal::before {
    content: 'แนะนำ';
    position: absolute;
    top: 0;
    right: 0;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-bottom-left-radius: 8px;
    font-weight: 600;
}

/* SEO Content */
.seo-content {
    margin-top: 50px;
    margin-bottom: 60px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.content-block {
    padding: 30px;
}

.content-block h2 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: var(--primary);
    font-family: var(--font-heading);
}

.content-block p {
    margin-bottom: 15px;
    color: var(--text-muted);
}

.content-block p strong {
    color: var(--text-main);
}

.age-table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.age-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.age-table th, .age-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--glass-border);
}

.age-table th {
    background: rgba(15, 23, 42, 0.8);
    font-weight: 600;
    color: var(--text-main);
}

.age-table tr:last-child td {
    border-bottom: none;
}

.age-table tbody tr {
    transition: background 0.2s;
}

.age-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.note {
    font-size: 0.9rem;
    font-style: italic;
    color: var(--accent) !important;
}

/* Footer */
.footer {
    margin-top: auto;
    text-align: center;
    padding: 30px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(2, 6, 23, 0.8);
}

/* Responsive */
@media (max-width: 600px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .calculator-glass {
        padding: 20px;
    }
    
    .tabs {
        flex-direction: column;
        gap: 5px;
    }
    
    .time-input {
        width: 100%;
        max-width: 250px;
    }
    
    .cards-container {
        grid-template-columns: repeat(2, 1fr);
    }
}
