/* --- Global Styles --- */
:root {
    --primary-color: #4DB6AC; /* Soft Teal */
    --primary-light: #E0F2F1;
    --primary-dark: #00796B;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-dark: #333;
    --text-light: #666;
    --border-color: #e9ecef;
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --success-color: #28a745;
    --info-color: #17a2b8;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
}

body {
    font-family: 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

/* --- ส่วน Header ที่อัปเดต --- */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 30px 20px;
    text-align: center;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Summary Content */
.day-summary-content {
    padding: 20px 25px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 1px solid var(--border-color);
    display: block; /* แสดงผลทันที */
}

/* Horizontal Scroll Layout */
.summary-grid {
    display: flex;
    gap: 20px;
    margin-bottom: 0;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.summary-grid::-webkit-scrollbar {
    height: 6px;
}

.summary-grid::-webkit-scrollbar-track {
    background: transparent;
}

.summary-grid::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.summary-grid::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Mobile Layout */
@media (max-width: 768px) {
    .day-summary-content {
        padding: 15px 20px;
    }
    
    .summary-item {
        padding: 15px 10px;
        min-width: 100px;
    }
    
    .summary-value {
        font-size: 1.3rem;
    }
    
    .day-info {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    
    .day-date {
        font-size: 0.9rem;
    }
    
    .day-title {
        font-size: 0.9rem;
    }
}

/* Small Mobile Layout */
@media (max-width: 480px) {
    .day-summary-content {
        padding: 12px 15px;
    }
    
    .summary-item {
        padding: 12px 8px;
        min-width: 90px;
    }
    
    .summary-value {
        font-size: 1.1rem;
    }
    
    summary {
        padding: 15px 20px;
        font-size: 1rem;
    }
    
    .day-info {
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }
    
    .day-date {
        font-size: 0.85rem;
    }
    
    .day-title {
        font-size: 0.85rem;
    }
    
    .locations-section {
        padding: 15px;
    }
    
    .location-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 6px 0;
    }
    
    .location-label {
        min-width: auto;
        font-size: 0.8rem;
    }
    
    .location-link {
        font-size: 0.9rem;
        padding: 6px 8px;
    }
    
    .estimated-expenses {
        padding: 12px;
    }
    
    .estimated-expenses h5 {
        font-size: 0.9rem;
    }
    
    .estimated-label {
        font-size: 0.85rem;
    }
    
    .estimated-value {
        font-size: 0.9rem;
    }
    
    .estimated-total .estimated-value {
        font-size: 1rem;
    }
}

/* Extra Small Mobile Layout */
@media (max-width: 360px) {
    summary {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    .day-info {
        flex-direction: row;
        align-items: center;
        gap: 4px;
    }
    
    .day-date {
        font-size: 0.8rem;
    }
    
    .day-title {
        font-size: 0.8rem;
    }
    
    .toggle-icon {
        font-size: 0.8rem;
    }
}

/* Expense Form Styles */
.expenses-form {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 15px;
}

.expense-fields-container {
    margin-bottom: 15px;
}

.expense-input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    gap: 8px;
}

.expense-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.expense-input-group label {
    min-width: 80px;
    font-weight: 500;
    color: var(--text-dark);
    flex-grow: 1;
}

.btn-remove-expense {
    background: transparent;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.btn-remove-expense:hover {
    background: #f8d7da;
    transform: scale(1.1);
}

.expense-actions {
    margin-bottom: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.btn-add-expense {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-add-expense:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.input-group {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.currency {
    background: var(--primary-light);
    padding: 8px 12px;
    color: var(--primary-dark);
    font-weight: 500;
    border-right: 1px solid var(--border-color);
}

.expense-input {
    border: none;
    padding: 8px 12px;
    width: 120px;
    font-size: 1rem;
    outline: none;
}

.expense-input:focus {
    background: #f8f9fa;
}

.expense-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: var(--primary-light);
    border-radius: 6px;
    margin: 15px 0;
    font-weight: 600;
    color: var(--primary-dark);
}

.total-amount {
    font-size: 1.2rem;
    color: var(--success-color);
}

.save-expenses-btn {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s ease;
    width: 100%;
}

.save-expenses-btn:hover {
    background: #218838;
}

/* Status Controls */
.trip-status-section {
    margin-top: 20px;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
}

.status-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 4px 8px;
}

.status-btn {
    background: white;
    border: 2px solid var(--border-color);
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 120px;
}

.status-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.status-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Location Groups */
.location-group {
    margin-bottom: 20px;
}

.location-group h5 {
    margin: 0 0 10px 0;
    color: var(--text-dark);
    font-size: 0.9rem;
    font-weight: 600;
}

.location-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.location-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.location-icon {
    font-size: 1rem;
    color: var(--primary-color);
    min-width: 20px;
}

.location-label {
    font-weight: 500;
    color: var(--text-light);
    font-size: 0.9rem;
    min-width: 80px;
}

.location-link {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    flex: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.location-link:hover {
    color: var(--primary-color);
    background: var(--primary-light);
    border-color: var(--primary-color);
    text-decoration: none;
}

/* Simple Location Items - New Style */
.location-item-simple {
    margin-bottom: 6px;
}

.location-link-simple {
    display: block;
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 8px 12px;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.location-link-simple:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Trip Status Visual Effects - Warm Tone with Minimal Animation */
.day-card.status-current summary {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    border: 2px solid #ff6b35;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
    position: relative;
    overflow: hidden;
}

/* Minimal Shimmer Animation for Active Status */
.day-card.status-current summary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: shimmer 3s ease-in-out infinite;
    z-index: 1;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    50% {
        left: 100%;
    }
    100% {
        left: 100%;
    }
}

.day-card.status-completed summary {
    background: linear-gradient(135deg, #6c757d, #adb5bd);
    color: #ffffff;
    opacity: 0.8;
}

.day-card.status-completed .day-title,
.day-card.status-completed .day-date {
    color: #6c757d;
}

.day-card.status-upcoming summary {
    background: linear-gradient(135deg, #e3f2fd, #f3e5f5);
    color: #666;
    border: 1px solid #e0e0e0;
}

.day-card.status-archived summary {
    background: linear-gradient(135deg, #fff8e1, #fce4ec);
    color: #888;
    border: 1px solid #f0f0f0;
}

/* Locations Section */
.locations-section {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 24px 36px;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* Expenses Section */
.expenses-section {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 8px 12px;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    width: 100%;
}

/* Trip Status Section */
.trip-status-section {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 8px 12px;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    width: 100%;
}

.locations-section h4,
.expenses-section h4,
.trip-status-section h4 {
    margin: 0 0 15px 0;
    color: var(--text-dark);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Estimated Expenses */
.estimated-expenses {
    margin-bottom: 20px;
    padding: 20px 36px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.estimated-expenses h5 {
    margin: 0 0 15px 0;
    color: var(--text-dark);
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.estimated-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.estimated-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.estimated-item:last-child {
    border-bottom: none;
}

.estimated-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-top: 8px;
    border-top: 2px solid var(--primary-color);
    font-weight: 600;
}

.estimated-label {
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 500;
}

.estimated-value {
    color: var(--primary-color);
    font-size: 0.95rem;
    font-weight: 600;
}

.estimated-total .estimated-value {
    color: var(--success-color);
    font-size: 1.1rem;
    font-weight: 700;
}

header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#total-summary {
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: white;
    padding: 15px 20px;
    border-radius: 15px;
    margin: 20px auto 0 auto;
    max-width: 400px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
#global-total-amount {
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* --- Main Content --- */
main {
    padding: 30px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

details {
    background-color: transparent;
    border-radius: 8px; 
    margin-bottom: 2px;
    box-shadow: none;
    border: none;
    overflow: hidden;
    transition: all 0.3s ease;
    padding: 0;
}

details:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

summary {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
    min-height: 40px;
    border-radius: 8px;
    margin-bottom: 4px;
}

summary:hover {
    background: linear-gradient(135deg, #e9ecef, #dee2e6);
}

/* Day Header - Horizontal Layout */
.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.day-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0; /* Allow text to wrap if needed */
}

.day-date {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 1rem;
}

.day-separator {
    color: var(--text-light);
    font-weight: 400;
}

.day-title {
    font-weight: 500;
    color: var(--text-dark);
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.day-toggle {
    display: flex;
    align-items: center;
    margin-left: 15px;
}

.toggle-icon {
    font-size: 0.9rem;
    color: var(--text-light);
    transition: transform 0.3s ease;
}

details[open] .toggle-icon {
    transform: rotate(180deg);
}


.day-content {
    padding: 20px 36px;
    background-color: #fafbfc;
    border-radius: 8px;
    margin-top: 4px;
}

h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 8px;
    margin-top: 30px;
    margin-bottom: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

h3:first-child {
    margin-top: 0;
}

.day-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 25px;
    background: linear-gradient(135deg, var(--primary-light), #f0f8f7);
    border-radius: 15px;
    margin-top: 15px;
    margin-bottom: 30px;
    border: 1px solid rgba(77, 182, 172, 0.2);
}

.summary-item {
    text-align: center;
    padding: 20px 15px;
    background: white;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(77, 182, 172, 0.2);
    flex-shrink: 0; /* ไม่ให้หดตัว */
    min-width: 120px; /* ความกว้างขั้นต่ำ */
}

.summary-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.summary-icon {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 5px;
    display: block;
}

.summary-label {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
    display: block;
}

.summary-item .icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 10px;
    color: var(--primary-color);
}
.summary-item strong {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 5px;
}
.summary-item span {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

.location-link {
    display: block;
    padding: 18px 20px;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    text-decoration: none;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.location-link:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(77, 182, 172, 0.2);
    text-decoration: none;
}

.location-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.location-name {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-dark);
    line-height: 1.4;
}

.expense-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.expense-item-readonly {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.expense-item-readonly:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(77, 182, 172, 0.1);
}

.expense-item-readonly span:first-child {
    font-size: 1rem;
    color: var(--text-dark);
    font-weight: 500;
}

.expense-item-readonly strong {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 700;
}

.expense-item-readonly small {
    display: block;
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 400;
    margin-top: 4px;
}

.total-row {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
}

.total-row:last-child {
    background: linear-gradient(135deg, var(--primary-light), #e8f5f3);
    border-color: var(--primary-color);
}

.total-row .total-actual {
    color: var(--primary-color);
    font-size: 1.4rem;
    font-weight: 700;
}

.save-btn {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-family: 'IBM Plex Sans Thai', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}
.save-btn:hover {
    background-color: #00796B; /* Darker Teal */
}
.save-btn:active {
    transform: scale(0.98);
}
.save-btn.saved {
    background-color: #66BB6A; /* Green */
}