@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&family=Phetsarath:wght@400;700&display=swap');

:root {
    --primary-color: #0e7490; /* Ocean teal */
    --primary-light: #e0f2fe; /* Light sky blue */
    --primary-dark: #155e75;
    --secondary-color: #10b981; /* Emerald green */
    
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --rating-1: #ef4444; /* Red */
    --rating-2: #f97316; /* Orange */
    --rating-3: #eab308; /* Yellow */
    --rating-4: #84cc16; /* Lime */
    --rating-5: #10b981; /* Green */

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 25px -5px rgba(15, 116, 144, 0.08), 0 8px 10px -6px rgba(15, 116, 144, 0.05);
    --shadow-lg: 0 20px 40px -15px rgba(15, 116, 144, 0.15);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Open Sans', sans-serif;
    background: linear-gradient(135deg, #f0f9ff 0%, #ecfdf5 100%);
    color: var(--text-main);
    line-height: 1.6;
    padding: 5.5rem 1rem 2rem; /* Space for Topbar */
    min-height: 100vh;
}

/* Lao Language Font Overrides */
body.lang-lo,
body.lang-lo input,
body.lang-lo select,
body.lang-lo textarea,
body.lang-lo button {
    font-family: 'Phetsarath', 'Open Sans', sans-serif !important;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* Topbar Styles */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 56px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-container {
    width: 100%;
    max-width: 800px;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Language Selector */
.lang-selector {
    position: relative;
    user-select: none;
}

.lang-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.lang-trigger:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.lang-trigger svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: var(--transition);
}

.lang-selector:hover .lang-trigger svg {
    color: var(--primary-color);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1100;
    min-width: 140px;
    animation: fadeIn 0.2s ease-out;
}

.lang-dropdown.active {
    display: flex;
}

.lang-option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.lang-option-item:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.lang-option-item.selected {
    font-weight: 600;
    background-color: rgba(14, 116, 144, 0.05);
    color: var(--primary-color);
}

.flag-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.flag-svg {
    width: 20px;
    height: 14px;
    display: inline-block;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    object-fit: cover;
}

/* Topbar Brand */
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 0.9rem;
    letter-spacing: -0.2px;
}

.topbar-brand svg {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
}

/* Header Cards */
.header-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.header-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.logo-container {
    width: 70px;
    height: 70px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: var(--primary-color);
    box-shadow: 0 8px 16px rgba(14, 116, 144, 0.1);
    font-size: 1.5rem; /* Text logo styling */
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-container svg {
    width: 36px;
    height: 36px;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    letter-spacing: -0.5px;
    text-transform: uppercase;
}

.intro-text {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 650px;
    margin: 0 auto;
}

/* General Info Section */
.section-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: var(--transition);
}

.section-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.section-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 0.75rem;
}

.section-title svg {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
}

input[type="text"],
input[type="tel"],
input[type="date"],
select,
textarea {
    font-family: inherit;
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: var(--transition);
    color: var(--text-main);
    background-color: #fafafa;
}

input[type="text"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.15);
}

.radio-group {
    display: flex;
    gap: 1.5rem;
    height: 100%;
    align-items: center;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400;
}

.radio-label input[type="radio"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    outline: none;
    transition: var(--transition);
    display: grid;
    place-content: center;
}

.radio-label input[type="radio"]::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transform: scale(0);
    transition: var(--transition);
    background-color: var(--primary-color);
}

.radio-label input[type="radio"]:checked {
    border-color: var(--primary-color);
}

.radio-label input[type="radio"]:checked::before {
    transform: scale(1);
}

/* Rating Scale Legend */
.legend-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.legend-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    list-style: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.legend-badge {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    color: white;
}

.badge-1 { background-color: var(--rating-1); } /* Red */
.badge-2 { background-color: var(--rating-3); } /* Yellow */
.badge-3 { background-color: var(--rating-5); } /* Green */

/* Survey Items Styling */
.survey-item {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.survey-item:last-of-type {
    border-bottom: none;
}

.item-question {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.item-question span.bullet {
    color: var(--primary-color);
    font-size: 1.2rem;
    line-height: 1;
}

/* 1-3 Rating Selector */
.rating-container {
    display: flex;
    justify-content: space-between;
    max-width: 240px; /* Reduced for 3 options */
    position: relative;
}

.rating-option {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rating-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.rating-label-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

/* Hover and Checked states per button index */
.rating-option:hover .rating-label-btn {
    transform: scale(1.12);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Color codes on hover/check (3 scale) */
.rating-option:nth-child(1):hover .rating-label-btn,
.rating-option:nth-child(1) input[type="radio"]:checked + .rating-label-btn {
    background-color: var(--rating-1);
    border-color: var(--rating-1);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.rating-option:nth-child(2):hover .rating-label-btn,
.rating-option:nth-child(2) input[type="radio"]:checked + .rating-label-btn {
    background-color: var(--rating-3);
    border-color: var(--rating-3);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(234, 179, 8, 0.4);
}

.rating-option:nth-child(3):hover .rating-label-btn,
.rating-option:nth-child(3) input[type="radio"]:checked + .rating-label-btn {
    background-color: var(--rating-5);
    border-color: var(--rating-5);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

/* Checked scaling */
.rating-option input[type="radio"]:checked + .rating-label-btn {
    transform: scale(1.15);
}

/* Label for rating explanation on active */
.rating-text {
    position: absolute;
    bottom: -20px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
    color: var(--text-muted);
}

.rating-option input[type="radio"]:checked ~ .rating-text {
    opacity: 1;
    bottom: -22px;
}

/* Other Specify Field */
.other-field {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Feedback cards style */
.textarea-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Submit Area */
.submit-container {
    text-align: center;
    margin: 3rem 0;
}

.btn-submit {
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-md);
    padding: 1rem 3rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(14, 116, 144, 0.3);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-submit:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(14, 116, 144, 0.4);
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
}

.btn-submit:active {
    transform: translateY(-1px);
}

.btn-submit:disabled,
.btn-submit.is-loading {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

.footer-text {
    text-align: center;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--primary-dark);
    margin-top: 2rem;
    font-style: italic;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000; /* Higher than Topbar */
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    max-width: 550px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: var(--transition);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #059669 100%);
    color: white;
    padding: 2rem;
    text-align: center;
    position: relative;
}

.modal-icon-container {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.modal-icon-container svg {
    width: 32px;
    height: 32px;
    color: white;
}

.modal-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
}

.modal-body {
    padding: 2rem;
    max-height: 60vh;
    overflow-y: auto;
}

.success-message {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.summary-details {
    background-color: var(--bg-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border-color);
}

.summary-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.summary-label {
    font-weight: 500;
    color: var(--text-muted);
}

.summary-value {
    font-weight: 600;
    color: var(--text-main);
}

.modal-footer {
    padding: 1.5rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.btn-close {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background-color: var(--primary-color);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.75rem 2rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-close:hover {
    background-color: var(--primary-dark);
}

/* Custom error message for validation */
.error-msg {
    color: var(--rating-1);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 0.25rem;
    display: none;
}

.invalid input[type="text"],
.invalid input[type="tel"],
.invalid select {
    border-color: var(--rating-1);
    background-color: #fffefc;
}

.invalid .error-msg {
    display: block;
}

.survey-item.invalid {
    border-left: 3px solid var(--rating-1);
    padding-left: 0.75rem;
}

.survey-item.invalid .item-question {
    color: var(--rating-1);
}

/* Tooltip style */
.required-star {
    color: var(--rating-1);
    margin-left: 0.25rem;
}

/* Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive tweaks */
@media (max-width: 600px) {
    body {
        padding: 5rem 0.5rem 1.5rem;
    }
    
    .header-card {
        padding: 2rem 1rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .section-card {
        padding: 1.5rem 1rem;
    }
    
    .rating-container {
        max-width: 100%;
    }
    
    .rating-label-btn {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
    
    .legend-list {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .legend-item {
        width: 100%;
    }
    
    .topbar-brand span {
        display: none; /* hide long name on super small mobile */
    }
}
