:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --secondary: #ec4899;
    --accent: #10b981;
    --bg-dark: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

html {
    overflow-x: hidden;
    width: 100%;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(100px);
    border-radius: 50%;
    opacity: 0.4;
    animation: move 20s infinite alternate;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: var(--secondary);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: var(--accent);
    top: 40%;
    left: 60%;
    animation-delay: -10s;
}

@keyframes move {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 100px) scale(1.2); }
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    color: var(--primary-light);
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: 12px;
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    border-left: 3px solid var(--primary);
}

.motto {
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
}

/* Content */
.content, .main-content {
    flex-grow: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
}

@media (min-width: 1025px) {
    .main-content {
        width: calc(100% - 260px);
    }
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 3rem;
}

.greeting h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.greeting p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.status-badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent);
}

/* Widgets Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr));
    gap: 2rem;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: var(--glass-shadow);
    transition: var(--transition);
}

.glass-panel:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
}

.widget-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    color: var(--primary-light);
}

.widget-header h3 {
    font-size: 1.25rem;
    color: var(--text-main);
}

/* Insight Card Specific */
.insight-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.1));
}

#insight-text {
    line-height: 1.6;
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Lists Styling */
.event-list, .email-list, .todo-list {
    list-style: none;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 15px;
    margin-bottom: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    transition: var(--transition);
}

.list-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

.item-info h4 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.item-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Todo Styling */
.add-todo {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

#new-todo {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: white;
    outline: none;
}

#add-todo-btn {
    background: var(--primary);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

#add-todo-btn:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 15px;
    margin-bottom: 0.75rem;
}

.todo-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--primary-light);
    cursor: pointer;
}

.todo-item.completed span {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Button Variations */
.btn-primary {
    background: var(--primary);
    border: none;
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.auth-buttons {
    display: flex;
    gap: 0.5rem;
    margin-right: 1rem;
}

/* Status Dot Variations */
.status-dot.disconnected {
    background: var(--text-muted);
    box-shadow: none;
}

.status-badge.disconnected {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
}

/* Booking Portal */
.booking-container {
    display: block;
    margin-top: 2rem;
}

.booking-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

.booking-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.glass-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    color: white;
    outline: none;
    transition: var(--transition);
}

.glass-input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
}

.slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.slot-chip {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--primary-light);
    padding: 0.75rem;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.slot-chip:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
}

.slot-chip.selected {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 15px var(--primary);
}

#booking-form-container {
    opacity: 0.5;
    pointer-events: none;
    transition: var(--transition);
}

.booking-form-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem;
}

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

.meeting-type-selector {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

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

.radio-label input {
    accent-color: var(--primary-color);
}

.w-full { width: 100%; }

.owner-only {
    display: none !important;
}

/* Responsive — Tablet (≤1024px) */
@media (max-width: 1024px) {
    .booking-layout { grid-template-columns: 1fr; }
    .sidebar { width: 80px; padding: 1.5rem 1rem; }
    .logo span, nav a span, .motto, .nav-item span { display: none; }
    .nav-item { justify-content: center; padding: 1rem; }
    .main-content { width: calc(100% - 80px); padding: 2rem; }
}

/* Responsive — Mobile (≤640px) */
@media (max-width: 640px) {
    /* Layout: sidebar thành top bar */
    .app-container { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        padding: 0.75rem 1rem;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        gap: 0.5rem;
        overflow-x: auto;
        z-index: 20;
    }
    .sidebar .logo { margin-bottom: 0; flex-shrink: 0; font-size: 1.1rem; }
    .sidebar nav {
        flex-direction: row;
        flex-grow: 1;
        gap: 0.25rem;
        justify-content: flex-end;
    }
    .sidebar .nav-item {
        padding: 0.5rem 0.75rem;
        justify-content: center;
        border-left: none;
    }
    .sidebar .nav-item.active { border-left: none; border-bottom: 2px solid var(--primary); }
    .sidebar .motto { display: none; }

    .main-content {
        width: 100% !important;
        padding: 1rem !important;
        max-width: 100vw;
    }

    /* Header */
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1.5rem;
        align-items: flex-start;
    }
    #greeting-text { font-size: 1.4rem; }
    #sub-greeting { font-size: 0.9rem; }
    .user-profile {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Widgets grid → 1 cột */
    .dashboard-grid { grid-template-columns: 1fr; gap: 1rem; }

    /* Booking → 1 cột (kế thừa tablet) */
    .booking-layout { gap: 1.5rem; }

    /* Override TẤT CẢ inline grid 1fr 1fr (giờ làm, lunch, buffer, cap, etc.) */
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Glass panels */
    .glass-panel {
        padding: 1rem;
        border-radius: 16px;
    }
    .glass-panel:hover { transform: none; }

    /* Settings grid trong admin panel — bớt padding */
    .settings-grid {
        padding: 1.25rem !important;
    }

    /* Slot chips nhỏ hơn cho dễ bấm trên mobile */
    .slots-grid {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
        gap: 0.5rem;
    }
    .slot-chip {
        padding: 0.6rem 0.4rem;
        font-size: 0.9rem;
    }

    /* Widget header sizes */
    .widget-header h3 { font-size: 1.05rem; }
    .widget-header h2 { font-size: 1.25rem; }

    /* Booking form */
    .booking-form-wrapper { padding: 1.25rem; }
    .meeting-type-selector { flex-direction: column; gap: 0.75rem; }

    /* Section-content padding */
    .section-content { padding: 1rem !important; }

    /* Success page */
    #success-section { padding: 2.5rem 1.25rem !important; }
    #success-section h2 { font-size: 1.5rem !important; }
    #success-section .success-icon { width: 70px !important; height: 70px !important; }
    #success-section p { font-size: 0.95rem !important; }

    /* Form inputs — font-size 16px chống iOS auto-zoom */
    .glass-input {
        font-size: 16px;
        padding: 0.75rem 0.9rem;
    }

    /* Buttons trên mobile */
    .btn-primary, .btn-secondary {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }
    .btn-sm {
        padding: 0.5rem 0.85rem;
        font-size: 0.85rem;
    }

    /* Save settings button: bớt padding inline */
    #save-settings-btn {
        padding: 0.85rem 1.5rem !important;
        font-size: 1rem !important;
        width: 100%;
        justify-content: center;
    }

    /* Background blobs nhỏ hơn để không lag */
    .blob-1, .blob-2, .blob-3 {
        width: 250px !important;
        height: 250px !important;
        filter: blur(60px);
    }
}

@media (max-width: 768px) {
    .app-container { 
        flex-direction: column;
        padding-bottom: 70px; /* Space for bottom nav */
    }
    
    .sidebar { 
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        border-right: none;
        border-top: 1px solid var(--glass-border);
        flex-direction: row;
        align-items: center;
        padding: 0 1rem;
        background: rgba(15, 23, 42, 0.9);
        backdrop-filter: blur(20px);
        box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    }

    .logo { display: none; }
    
    nav { 
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
        gap: 0;
    }

    .nav-item {
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.5rem;
        background: none !important;
        border: none !important;
        font-size: 0.7rem;
    }

    .nav-item i { width: 20px; height: 20px; }
    .nav-item span { display: block; }
    .nav-item.active { color: var(--primary-light); }

    .main-content { 
        width: 100%;
        padding: 1.5rem 1rem;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }

    .greeting h1 { font-size: 1.8rem; }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .glass-panel { padding: 1.25rem; }

    .booking-form-wrapper { padding: 1.25rem; }
    
    .slots-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .booking-portal h2 {
        font-size: 1.5rem;
    }

    .booking-container {
        margin-top: 1rem;
        gap: 1.5rem;
    }

    .booking-layout {
        grid-template-columns: 1fr;
    }

    #success-section {
        padding: 3rem 1.5rem !important;
    }

    #success-section h2 {
        font-size: 1.5rem;
    }
}
