/* ตัวแปรสี - กำหนดสีหลักของแอพ */
:root {
    --bg-color: #f2f2f2;
    --card-bg: #ffffff;
    --border-color: #e0e0e0;
    --primary-color: #007AFF;
    --text-color: #333333;
    --text-secondary: #666666;
    
    /* สีพาสเทลสำหรับขอบรุ้ง */
    --pastel-blue: #abd8f2;
    --pastel-green: #c3e8ca;
    --pastel-pink: #f9c9d7;
    --pastel-yellow: #fff2bd;
    --pastel-purple: #dfd0f5;
    --pastel-orange: #ffd8b5;

    /* สีสำหรับสวิตช์โหมด */
    --toggle-bg: #f0f0f0;
    --toggle-color-general: #007AFF;
    --toggle-color-government: #4cd964;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

/* iOS Status Bar */
.status-bar {
    background-color: #000000;
    color: white;
    padding: 5px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.time {
    font-weight: 500;
    font-size: 18px;
}

.status-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Header Navigation */
.nav-header {
    background-color: rgba(242, 242, 242, 0.92);
    padding: 12px 15px;
    text-align: center;
    position: relative;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-title {
    font-size: 18px;
    font-weight: 500;
    flex: 1;
    text-align: center;
    color: #333;
}

.nav-menu {
    display: flex;
    gap: 3px;
    margin-right: 5px;
}

.nav-menu-dot {
    width: 5px;
    height: 5px;
    background-color: #ff6b6b;
    border-radius: 50%;
}

/* Main App Container with Triple Border */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    box-shadow: 
        0 0 0 8px var(--pastel-blue),    /* ชั้นแรก - สีฟ้าพาสเทล */
        0 0 0 16px var(--pastel-green),  /* ชั้นที่สอง - สีเขียวพาสเทล */
        0 0 0 24px var(--pastel-pink);   /* ชั้นที่สาม - สีชมพูพาสเทล */
    border-radius: 20px;
    overflow: hidden;
    margin: 30px;
}

/* Rainbow Border */
.rainbow-border {
    position: relative;
    display: flex;
    margin: 0;
    padding: 0;
    height: 100%;
    border-radius: 10px;
    overflow: hidden;
}

.rainbow-left {
    width: 20px;
    background: linear-gradient(to bottom, 
        var(--pastel-blue), 
        var(--pastel-green), 
        var(--pastel-yellow),
        var(--pastel-orange));
    border-top-left-radius: 15px;
    border-bottom-left-radius: 15px;
}

.rainbow-right {
    width: 20px;
    background: linear-gradient(to bottom, 
        var(--pastel-blue), 
        var(--pastel-purple), 
        var(--pastel-pink),
        var(--pastel-orange));
    border-top-right-radius: 15px;
    border-bottom-right-radius: 15px;
}

/* Content Section */
.app-content {
    flex: 1;
    padding: 0;
    font-size: 18px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

/* ส่วนของหน้าต่างๆ */
.page {
    display: none;
    flex: 1;
    flex-direction: column;
    height: 100%;
}

.page.active {
    display: flex;
}

/* หน้าหลัก */
.homepage {
    padding: 20px;
    background-color: #f9f9f9;
    overflow-y: auto;
}

.app-title {
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
}

.app-description {
    font-size: 17px;
    line-height: 1.5;
    margin-bottom: 25px;
    color: #555;
}

.copyright {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 25px;
    text-align: center;
}

/* Infographic Section */
.infographic {
    background-color: white;
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.infographic-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

.infographic-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

/* Infographic Items */
.info-item {
    background-color: #f9f9f9;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.info-item:hover {
    transform: translateY(-2px);
}

.info-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    border-radius: 10px 0 0 10px;
}

.info-item:nth-child(1)::before {
    background-color: var(--pastel-blue);
}

.info-item:nth-child(2)::before {
    background-color: var(--pastel-pink);
}

.info-item:nth-child(3)::before {
    background-color: var(--pastel-green);
}

.info-item:nth-child(4)::before {
    background-color: var(--pastel-orange);
}

.info-icon {
    width: 50px;
    height: 50px;
    background-color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    font-size: 24px;
}

.info-title {
    font-weight: 600;
    margin-bottom: 5px;
    text-align: center;
    color: #444;
    font-size: 16px;
}

.info-value {
    color: var(--text-secondary);
    text-align: center;
    font-size: 14px;
}

/* หน้ากรอกข้อมูล */
.input-page {
    display: flex;
    flex: 1;
}

/* Input Sidebar */
.input-sidebar {
    background-color: white;
    width: 120px;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    border-right: 1px solid #eee;
}

.sidebar-label {
    margin: 5px 0;
    font-size: 24px;
    font-weight: 500;
    text-align: center;
    color: #555;
}

.blue-line {
    width: 60px;
    height: 3px;
    background-color: var(--primary-color);
    margin: 10px 0;
}

/* ช่องเลือกวันที่ */
.select-container {
    margin: 5px 0;
    width: 100%;
    display: flex;
    justify-content: center;
}

.select-wrapper {
    position: relative;
    width: 90px;
    height: 90px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    justify-content: center;
    align-items: center;
}

.select-arrow {
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid #aaa;
    position: relative;
    top: 5px;
}

/* Input Content */
.input-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    background-color: #f9f9f9;
}

.input-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.input-description {
    margin-bottom: 20px;
    font-size: 16px;
    text-align: center;
    color: #666;
}

/* Mode Toggle Switch */
.mode-toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    gap: 15px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--toggle-bg);
    transition: .4s;
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: var(--toggle-color-general);
    transition: .4s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: var(--toggle-bg);
}

input:checked + .slider:before {
    transform: translateX(26px);
    background-color: var(--toggle-color-government);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.mode-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-color);
}

.date-input-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.date-group {
    background-color: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.date-group-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #444;
}

.date-selects {
    display: flex;
    gap: 10px;
}

.date-select {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background-color: white;
    font-size: 16px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.calculate-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px 20px;
    font-size: 18px;
    font-weight: 500;
    margin-top: 30px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.calculate-btn:hover {
    background-color: #0062cc;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

/* หน้าแสดงผล */
.results-page {
    padding: 20px;
    background-color: #f9f9f9;
    overflow-y: auto;
}

.results-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 25px;
    text-align: center;
    color: #333;
}

.results-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-card {
    background-color: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
}

.result-card:nth-child(1)::before {
    background-color: var(--pastel-blue);
}

.result-card:nth-child(2)::before {
    background-color: var(--pastel-green);
}

.result-card:nth-child(3)::before {
    background-color: var(--pastel-blue);
}

.result-card:nth-child(4)::before {
    background-color: var(--pastel-green);
}

/* สีสำหรับกล่องวันเกษียณ */
#retirement-date-container::before {
    background-color: var(--toggle-color-government);
}

.result-label {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #444;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.result-value {
    font-size: 20px;
    font-weight: 500;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 10px;
    color: #333;
}

.result-note {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
}

.result-slider {
    width: 100%;
    height: 10px;
    background-color: #eee;
    border-radius: 5px;
    margin-top: 15px;
    position: relative;
    overflow: hidden;
}

.result-slider-fill {
    position: absolute;
    height: 100%;
    background: linear-gradient(to right, var(--pastel-blue), var(--pastel-purple));
    border-radius: 5px;
    width: 0; /* จะถูกตั้งค่าด้วย JavaScript */
}

.back-btn {
    background-color: #f5f5f5;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 500;
    margin-top: 25px;
    cursor: pointer;
    display: block;
    width: 100%;
    text-align: center;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background-color: #eee;
}

/* Bottom Navigation Bar */
.tab-bar {
    display: flex;
    background-color: white;
    border-top: 1px solid var(--border-color);
}

.tab-item {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    color: #777;
    transition: color 0.3s;
}

.tab-item.active {
    color: var(--primary-color);
}

.tab-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.tab-label {
    font-size: 12px;
    text-align: center;
}

/* Footer Navigation */
.navigation-footer {
    background-color: rgba(242, 242, 242, 0.9);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
}

.page-indicator {
    font-size: 16px;
    color: var(--text-secondary);
}

.nav-arrows {
    display: flex;
    gap: 20px;
}

.nav-arrow {
    width: 25px;
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Reply Box */
.reply-box {
    background-color: #f9f9f9;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-color);
}

.reply-label {
    color: var(--text-secondary);
    font-size: 18px;
}

.reply-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.reply-button {
    width: 40px;
    height: 40px;
    background-color: #f2f2f2;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

/* Home Indicator */
.home-indicator {
    height: 5px;
    width: 30%;
    margin: 5px auto;
    background-color: #000;
    border-radius: 3px;
}

/* Media Queries for Responsive Design */
@media (max-width: 768px) {
    .input-page {
        flex-direction: column;
    }
    
    .input-sidebar {
        width: 100%;
        height: auto;
        padding: 10px;
        flex-direction: row;
        justify-content: space-around;
        border-right: none;
        border-bottom: 1px solid #eee;
    }
    
    .sidebar-label {
        font-size: 16px;
        margin: 0 5px;
    }
    
    .blue-line {
        width: 40px;
        margin: 0 10px;
    }
    
    .select-container {
        margin: 0 5px;
    }
    
    .select-wrapper {
        width: 60px;
        height: 60px;
    }
    
    .date-selects {
        flex-direction: column;
    }
    
    .infographic-grid {
        grid-template-columns: 1fr;
    }
    
    /* ปรับขอบจอสำหรับแท็บเล็ต */
    .app-container {
        margin: 20px;
        box-shadow: 
            0 0 0 6px var(--pastel-blue),
            0 0 0 12px var(--pastel-green),
            0 0 0 18px var(--pastel-pink);
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 22px;
    }
    
    .results-title {
        font-size: 20px;
    }
    
    .result-value {
        font-size: 16px;
        padding: 10px;
    }
    
    .calculate-btn, .back-btn {
        padding: 12px 15px;
        font-size: 16px;
    }
    
    .tab-icon {
        font-size: 20px;
    }
    
    .tab-label {
        font-size: 10px;
    }
    
    /* ปรับขอบจอสำหรับมือถือ */
    .app-container {
        margin: 10px;
        box-shadow: 
            0 0 0 4px var(--pastel-blue),
            0 0 0 8px var(--pastel-green),
            0 0 0 12px var(--pastel-pink);
    }
}