:root {
    --primary-color: #1a237e;
    --accent-color: #2196f3;
    --success-color: #4caf50;
    --error-color: #f44336;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    --border-color: #e0e6ed;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: var(--card-bg);
    padding: 1.5rem 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.logo-section h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    font-weight: 700;
}

.logo-section h1 span {
    color: var(--accent-color);
    font-weight: 300;
}

.logo-section p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.user-info-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.user-section {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.user-section label {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-color);
}

.user-section input {
    padding: 1rem 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1.1rem;
    width: 100%;
    transition: var(--transition);
    background: white;
}

.user-section input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.1);
}

.notice-box {
    background-color: #fff9c4;
    border-left: 5px solid #fbc02d;
    padding: 1.2rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.notice-title {
    font-weight: 700;
    color: #f57f17;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notice-box ul {
    list-style-type: none;
    padding-left: 0;
}

.notice-box li {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #5d4037;
    position: relative;
    padding-left: 1.5rem;
}

.notice-box li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #fbc02d;
    font-weight: bold;
}

main {
    flex: 1;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.status-legend {
    display: flex;
    gap: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.available .dot { background-color: #e3f2fd; border: 1px solid var(--accent-color); }
.selected .dot { background-color: var(--accent-color); }
.busy .dot { background-color: #f5f5f5; border: 1px solid #ddd; }

.mobile-day-selector {
    display: none;
}

/* Grid Layout */
.calendar-grid {
    display: grid;
    grid-template-columns: 100px repeat(7, 1fr);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.grid-header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.time-label {
    background-color: #f8fafc;
    padding: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.slot {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    min-height: 80px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
}

.slot:hover:not(.busy) {
    background-color: rgba(33, 150, 243, 0.05);
}

.slot.selected {
    background-color: rgba(33, 150, 243, 0.1) !important;
    border: 2px solid var(--accent-color);
}

.slot.busy {
    background-color: #d1d5db; /* Xám đậm hơn */
    cursor: not-allowed;
    opacity: 0.8;
}

.slot.busy::after {
    content: "Hết chỗ";
    font-size: 0.75rem;
    font-weight: 700;
    color: #4b5563;
    margin-top: 5px;
}

/* Checkbox/Select indicator styles */
.slot-checkbox {
    width: 20px;
    height: 20px;
    margin-top: 10px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.slot-time {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Footer Section */
footer {
    margin-top: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 1.5rem 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.selection-summary {
    font-size: 1rem;
    color: var(--text-muted);
}

.selection-summary strong {
    color: var(--primary-color);
}

button#submit-btn {
    padding: 1rem 2.5rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

button#submit-btn:hover:not(:disabled) {
    background-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 35, 126, 0.2);
}

button#submit-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none; /* Controlled by JS */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: white;
    text-align: center;
}

.loading-overlay p {
    font-size: 1.1rem;
    font-weight: 500;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 2rem;
    border-radius: 16px;
    width: 400px;
    box-shadow: var(--shadow);
    text-align: center;
    position: relative;
}

.close {
    position: absolute;
    right: 20px; top: 10px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

/* Responsive Mobile */
@media (max-width: 768px) {
    .app-container { padding: 1rem; }
    header { flex-direction: column; text-align: center; gap: 1.5rem; }
    .user-section input { width: 100%; }
    
    .calendar-controls { flex-direction: column; gap: 1rem; align-items: flex-start; }
    .mobile-day-selector { display: block; width: 100%; }
    #day-select-mobile {
        width: 100%;
        padding: 0.8rem;
        border: 2px solid var(--border-color);
        border-radius: 8px;
        font-size: 1rem;
    }

    .calendar-grid { display: none; } /* Hide grid on mobile */
    
    /* Mobile-specific list of slots */
    .mobile-slots-list {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        padding-bottom: 2rem;
    }

    .mobile-day-group {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
    }

    .mobile-day-header {
        background: var(--primary-color);
        color: white;
        padding: 0.8rem 1.2rem;
        border-radius: 8px;
        font-weight: 700;
        font-size: 1rem;
        position: sticky;
        top: 0;
        z-index: 5;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .mobile-slot-item {
        background: #f8fafc;
        border: 1px solid var(--border-color);
        padding: 1.2rem;
        border-radius: 12px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        transition: var(--transition);
    }
    
    .mobile-slot-item.selected {
        background: var(--accent-color);
        color: white;
        border-color: var(--accent-color);
    }
    
    .mobile-slot-item.busy {
        opacity: 0.5;
        cursor: not-allowed;
    }

    footer { flex-direction: column; gap: 1.5rem; text-align: center; }
    button#submit-btn { width: 100%; }
}
