:root {
    --cal-bg: #050812;
    --cal-surface: rgba(20, 20, 30, 0.98);
    --cal-surface-hover: rgba(40, 40, 50, 0.98);
    --cal-border: rgba(255, 255, 255, 0.1);
    
    /* Matching styles.css theme colors */
    --cal-primary: #6365e8; /* --accent-solid */
    --cal-secondary: #c751e7; /* End of gradient */
    --cal-accent-gradient: linear-gradient(90deg, #6365e8 0%, #c751e7 100%); /* --accent-gradient */
    
    --cal-text: #E6EDF3; /* --text-primary */
    --cal-text-muted: #9CA3AF; /* --text-muted */
    --cal-success: #7EE787; /* --success */
    
    --cal-glow: 0 0 20px rgba(99, 101, 232, 0.3);
    --cal-font: 'Manrope', system-ui, -apple-system, sans-serif;
    --cal-font-heading: 'Manrope', system-ui, -apple-system, sans-serif;
    --cal-font-body: 'Sora', system-ui, -apple-system, sans-serif;
    
    --cal-z-index: 9999;
}

/* Floating Widget Container - Fixed Size, No Scroll */
#calendar-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: var(--cal-z-index);
    width: 800px;
    height: 500px;
    background: rgba(5, 8, 18, 0.95); /* Matches --bg-primary with opacity */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08); /* Matches styles.css border style */
    border-radius: 24px; /* Matches --card-radius */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.22, 0.9, 0.2, 1); /* Matches --transition */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    font-family: var(--cal-font-body);
}

#calendar-widget-container.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

#calendar-widget-container.minimized {
    width: 200px; /* Rectangular tab width */
    height: 48px; /* Tab height */
    border-radius: 12px 12px 0 0; /* Rounded top corners only */
    bottom: 0; /* Stick to bottom */
    right: 100px; /* Offset to sit next to chatbot (chatbot is usually ~20px right + 60px width) */
    overflow: hidden;
    cursor: pointer;
    background: var(--cal-surface);
    border: 1px solid var(--cal-border);
    border-bottom: none;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0); /* Ensure it sits visible at bottom */
}

#calendar-widget-container.minimized:hover {
    background: var(--cal-surface-hover);
    transform: translateY(-4px); /* Slight peek effect */
}

/* Ensure minimized content centers text/icon */
.minimized-content {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: flex-start; /* Align text leftish */
    padding: 0 1rem;
    gap: 10px;
    font-weight: 600;
    color: var(--cal-text);
    font-size: 0.95rem;
}

.minimized-content svg {
    width: 20px;
    height: 20px;
    color: var(--cal-primary);
}

#calendar-widget-container.minimized .minimized-content {
    display: flex;
}

#calendar-widget-container.minimized .calendar-content-wrapper,
#calendar-widget-container.minimized .calendar-widget-header {
    display: none;
}

/* Header */
.calendar-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    user-select: none;
    height: 50px;
    box-sizing: border-box;
}

.calendar-widget-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--cal-font-heading);
    font-weight: 700;
    color: var(--cal-text);
    font-size: 1rem;
    background: var(--cal-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.calendar-widget-controls {
    display: flex;
    gap: 8px;
}

.widget-control-btn {
    background: transparent;
    border: none;
    color: var(--cal-text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
}

.widget-control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--cal-text);
}

/* Main Content Area */
.calendar-content-wrapper {
    display: grid;
    grid-template-columns: 1fr 280px;
    height: calc(500px - 50px);
    overflow: hidden;
}

/* Left: Calendar Grid Area */
.calendar-main-area {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.calendar-top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.5rem;
}

.year-nav {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    justify-content: space-between;
}

.year-nav button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--cal-text);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.year-nav button:hover {
    border-color: var(--cal-primary);
    color: var(--cal-primary);
}

.current-year-display {
    font-family: var(--cal-font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--cal-text);
}

/* Compact Month List */
.month-scroll-container {
    display: flex;
    justify-content: center;
    padding-bottom: 4px;
}

.month-list {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    width: 100%;
}

.month-pill {
    background: transparent;
    border: 1px solid transparent;
    color: var(--cal-text-muted);
    padding: 0.25rem 0.2rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    font-family: var(--cal-font-body);
}

.month-pill:hover {
    color: var(--cal-text);
    background: rgba(255, 255, 255, 0.05);
}

.month-pill.active {
    background: rgba(99, 101, 232, 0.15);
    color: var(--cal-primary);
    border-color: rgba(99, 101, 232, 0.3);
}

/* Calendar Grid */
.calendar-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    color: var(--cal-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    font-family: var(--cal-font-heading);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 4px;
    flex: 1;
    align-content: stretch;
}

.cal-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    position: relative;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.02);
    min-height: 0;
}

.cal-day:hover:not(.empty):not(.disabled) {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.cal-day.empty {
    background: transparent;
    cursor: default;
}

.cal-day.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: transparent;
}

.cal-day.selected {
    background: var(--cal-accent-gradient);
    color: var(--bg-primary); /* Dark text on gradient */
    box-shadow: 0 0 10px rgba(99, 101, 232, 0.3);
    color: #050812;
    font-weight: 700;
}

.cal-day.today {
    border: 1px solid var(--cal-primary);
    color: var(--cal-primary);
}

.cal-day.selected.today {
    color: #050812;
    border-color: transparent;
}

/* Right: Sidebar Area */
.calendar-sidebar-area {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.selected-date-info {
    flex-shrink: 0;
}

.selected-date-info h3 {
    margin: 0;
    font-family: var(--cal-font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--cal-text);
    background: var(--cal-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.selected-date-info p {
    margin: 2px 0 0 0;
    color: var(--cal-text-muted);
    font-size: 0.85rem;
}

/* Time Slots Grid (Compact) */
.time-slots-list {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    align-content: start;
    padding-right: 4px;
}

.time-slots-list::-webkit-scrollbar {
    width: 4px;
}
.time-slots-list::-webkit-scrollbar-thumb {
    background: var(--cal-accent-gradient);
    border-radius: 4px;
}

.time-slot-item {
    padding: 0.5rem 0.2rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    text-align: center;
}

.time-slot-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--cal-primary);
}

.time-slot-item.selected {
    background: rgba(99, 101, 232, 0.15);
    border-color: var(--cal-primary);
    color: var(--cal-text);
}

.time-slot-item.booked {
    opacity: 0.4;
    text-decoration: line-through;
    cursor: not-allowed;
    background: rgba(255, 0, 0, 0.05);
}

/* Checkboxes Section */
.terms-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--cal-text-muted);
    background: rgba(255,255,255,0.03);
    padding: 8px;
    border-radius: 8px;
    margin-top: auto;
}

.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.checkbox-group input {
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--cal-primary);
}

.checkbox-group label a {
    color: var(--cal-primary);
    text-decoration: none;
}

.checkbox-group label a:hover {
    text-decoration: underline;
}

.confirm-btn {
    width: 100%;
    padding: 0.8rem;
    background: var(--cal-accent-gradient);
    border: none;
    border-radius: 12px; /* Matches --btn-radius */
    color: #050812; /* Dark text for contrast on gradient */
    font-weight: 700;
    font-family: var(--cal-font-body);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.confirm-btn:hover:not(:disabled) {
    transform: scale(1.04);
    box-shadow: 0 8px 24px rgba(99, 101, 232, 0.3);
}

.confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.1);
    color: var(--cal-text-muted);
}

/* Mobile Responsiveness */
@media (max-width: 850px) {
    #calendar-widget-container {
        width: 94%;
        height: 600px;
        right: 3%;
        left: 3%;
        bottom: 20px;
        transform: translateY(20px);
    }
    
    #calendar-widget-container.active {
        transform: translateY(0);
    }
    
    .calendar-content-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: calc(600px - 50px);
        overflow-y: auto;
    }
    
    .calendar-main-area {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        min-height: 350px;
    }
    
    .calendar-sidebar-area {
        min-height: 250px;
    }
}
