﻿/* =========================================
   1. MAIN LAYOUT ROOT (.t-scheduler)
   ========================================= */

.t-scheduler {
    /* Reset the outer container */
    border: none !important;
    display: flex;
    border-radius: 0 !important;
    background-color: transparent !important;
    box-shadow: none !important;
    gap: 16px;
    height: 100%;
    width: 100%;
    overflow: hidden; /* Prevent outer scroll */
}

/* --- Main Calendar Area --- */
.t-scheduler__main {
    border: 1px solid var(--mud-palette-table-lines);
    border-radius: var(--t-border-radius);
    background-color: var(--mud-palette-surface);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0; /* Flexbox fix for overflowing children */
}

/* --- Header Section --- */
.t-scheduler__header {
    padding: 8px 12px; /* Slightly more side padding */
    border-bottom: 1px solid var(--mud-palette-table-lines);
    background-color: var(--mud-palette-surface);
    flex-shrink: 0;
    /* Flex Behavior */
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* Allows items to stack on small screens */
    gap: 12px; /* Space between groups */
}

/* --- Content/Body Section --- */
.t-scheduler__content {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
    background-color: var(--mud-palette-background);
}

/* --- View Switcher (Scoped) --- */
.t-scheduler__view-switcher {
    border: 1px solid var(--mud-palette-lines-default) !important;
    border-radius: 16px !important;
    overflow: hidden;
    background-color: var(--mud-palette-surface);
}

    /* Target MudBlazor buttons specifically inside the switcher */
    .t-scheduler__view-switcher .mud-button-root {
        border: none !important;
        border-radius: 0 !important;
        border-right: 1px solid var(--mud-palette-lines-default) !important;
        height: 36px;
        font-weight: 500;
        font-size: 0.875rem;
        text-transform: none;
        color: var(--mud-palette-text-primary);
        margin: 0 !important;
        padding: 0 12px !important; /* Reduce padding slightly */
        min-width: 40px; /* Allow buttons to shrink to icon-only size */
    }

        .t-scheduler__view-switcher .mud-button-root:last-child {
            border-right: none !important;
            border-bottom-right-radius: 16px !important;
            border-top-right-radius: 16px !important;
        }

        .t-scheduler__view-switcher .mud-button-root:first-child {
            border-bottom-left-radius: 16px !important;
            border-top-left-radius: 16px !important;
        }

    /* Active State */
    .t-scheduler__view-switcher .t-scheduler__btn--active {
        background-color: rgba(var(--mud-palette-primary-rgb), 0.12) !important;
        color: var(--mud-palette-primary) !important;
    }

        .t-scheduler__view-switcher .t-scheduler__btn--active .mud-icon-root {
            color: var(--mud-palette-primary) !important;
        }

    /* Hover State */
    .t-scheduler__view-switcher .mud-button-root:not(.t-scheduler__btn--active):hover {
        background-color: var(--mud-palette-action-default-hover) !important;
    }


/* =========================================
   2. SIDE PANEL
   ========================================= */

.t-scheduler__side-panel {
    background-color: transparent !important;
    border-left: none !important;
    position: relative;
    /* ANIMATION SETUP */
    width: 0; /* Start closed */
    opacity: 0;
    /* Animate Width (layout) and Opacity (visual) */
    transition: width 0.2s ease-in-out, opacity 0.2s ease-in-out;
    overflow: hidden; /* Crucial: Hides content as width shrinks */
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* Prevent flexbox from forcing it open */
}

    /* OPEN STATE */
    .t-scheduler__side-panel.is-open {
        width: 400px;
        opacity: 1;
        border-left: 1px solid transparent; /* Optional: Restore border only when open */
    }

/* INNER WRAPPER 
       Keeps content at fixed width so it doesn't squish while animating */
.t-scheduler__side-panel-inner {
    width: 400px;
    height: 100%;
    display: flex; /* Critical for the fix */
    flex-direction: column; /* Critical for the fix */
    position: relative;
}

/* Close Button Wrapper */
.t-scheduler__side-panel .t-scheduler__close-btn {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 100;
    padding: 0px !important;
}

    .t-scheduler__side-panel .t-scheduler__close-btn .mud-button-root {
        padding: 3px;
    }

/* Specific overrides for your Card components inside the panel */
.t-scheduler__side-panel.activity .t-card-base-container {
    position: relative;
    overflow: hidden;
}

.t-scheduler__side-panel.activity .t-gcard-header {
    background-color: transparent !important;
    pointer-events: none;
}

.t-scheduler__side-panel.activity .t-gcard-button-container {
    pointer-events: all;
    z-index: 111;
    margin-right: 32px;
}

.t-scheduler__side-panel.activity .t-gcard-date-container {
    display: none;
}

/* Specific overrides for your Card components inside the panel */

/* Apply to Panel Mode OR Inline Draft */
.t-scheduler__side-panel.activity .t-card-base-container,
.t-scheduler__inline-draft .t-card-base-container { /* <--- ADDED THIS */
    position: relative;
    overflow: hidden;
}

/* Apply to Panel Mode OR Inline Draft */
.t-scheduler__side-panel.activity .t-gcard-header,
.t-scheduler__inline-draft .t-gcard-header { /* <--- ADDED THIS */
    background-color: transparent !important;
    pointer-events: none;
}

/* Apply to Panel Mode OR Inline Draft */
.t-scheduler__side-panel.activity .t-gcard-button-container,
.t-scheduler__inline-draft .t-gcard-button-container { /* <--- ADDED THIS */
    pointer-events: all;
    z-index: 111;
}

/* Apply to Panel Mode OR Inline Draft */
.t-scheduler__side-panel.activity .t-gcard-date-container,
.t-scheduler__inline-draft .t-gcard-date-container { /* <--- ADDED THIS */
    display: none;
}

/* --- Optional: Add visual separation for the draft in the list --- */
.t-scheduler__inline-draft {
    margin-bottom: 8px;
    /* Optional: Add a dashed border to highlight it's a draft, similar to week view */
    /* border: 1px dashed var(--mud-palette-primary); */
    /* border-radius: 8px; */
}

/* =========================================
   3. MONTH VIEW
   ========================================= */

.t-scheduler__month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: 30px repeat(6, 1fr);
    height: 100%;
    min-height: 600px;
}

    .t-scheduler__month-grid .t-scheduler__month-header-cell {
        text-align: center;
        font-weight: bold;
        border-bottom: 1px solid var(--mud-palette-table-lines);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .t-scheduler__month-grid .t-scheduler__month-day-cell {
        border-right: 1px solid var(--mud-palette-table-lines);
        border-bottom: 1px solid var(--mud-palette-table-lines);
        padding: 4px;
        min-height: 80px;
        display: flex;
        flex-direction: column;
        background-color: var(--mud-palette-surface);
        transition: background-color 0.1s;
        height: 100%;
        max-height: 100%;
        overflow: hidden; /* Essential for the scroll mask to work properly */
        cursor: pointer;
        position: relative; /* Context for stacking */
        transition: background-color 0.1s ease-in-out;
    }

        .t-scheduler__month-grid .t-scheduler__month-day-cell:hover {
            background-color: rgba(var(--mud-palette-primary-rgb), 0.08) !important;
        }

        .t-scheduler__month-grid .t-scheduler__month-day-cell.is-dimmed {
            opacity: 0.4;
            background-color: var(--mud-palette-background-grey);
        }


        .t-scheduler__month-grid .t-scheduler__month-day-cell.is-selected {
            background-color: rgba(var(--mud-palette-primary-rgb), 0.16) !important;
            box-shadow: inset 0 0 0 2px var(--mud-palette-primary);
        }


    .t-scheduler__month-grid .t-scheduler__day-num {
        text-align: right;
        font-size: 0.8rem;
        color: var(--mud-palette-text-secondary);
        margin-bottom: 2px;
        flex-shrink: 0;
    }

    .t-scheduler__month-grid .t-scheduler__month-day-cell.is-today .t-scheduler__day-num {
        border: 1px solid var(--mud-palette-primary);
        border-radius: 50%;
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;
    }

    .t-scheduler__week-header .t-scheduler__day-header.is-today .t-scheduler__day-num {
        border: 2px solid var(--mud-palette-primary);
        border-radius: 50%;
        width: 24px;
        height: 24px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* --- SCROLL STACK WITH FADE EFFECT --- */
    .t-scheduler__month-grid .t-scheduler__stack {
        display: flex;
        flex-direction: column;
        gap: 3px;
        overflow-y: auto; /* Allows scrolling */
        flex-grow: 1;
        padding-right: 0;
        max-height:66%;
        /* Add padding at bottom so last item isn't fully faded */
        padding-bottom: 15px;
        /* Hide Scrollbar (Standard) */
        scrollbar-width: none;
        -ms-overflow-style: none;
        /* Mask Logic: Fades the bottom 15% to transparent */
        mask-image: linear-gradient(to bottom, black 85%, transparent 100%);
        -webkit-mask-image: linear-gradient(to bottom, black 85%, transparent 100%);
    }

        /* Hide Scrollbar (Webkit/Chrome) */
        .t-scheduler__month-grid .t-scheduler__stack::-webkit-scrollbar {
            display: none;
        }


/* =========================================
   4. WEEK / DAY VIEW
   ========================================= */

.t-scheduler__week-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* Header Row (Mon 12, Tue 13...) */
.t-scheduler__week-header {
    display: grid;
    border-bottom: 1px solid var(--mud-palette-table-lines);
    background: var(--mud-palette-surface);
    flex-shrink: 0;
    z-index: 2;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

    .t-scheduler__week-header .t-scheduler__day-header {
        text-align: center;
        padding: 8px;
        border-left: 1px solid var(--mud-palette-table-lines);
        font-weight: 500;
        cursor: pointer;
        transition: background-color 0.1s;
    }

        .t-scheduler__week-header .t-scheduler__day-header:hover {
            background-color: var(--mud-palette-action-default-hover);
        }

        .t-scheduler__week-header .t-scheduler__day-header.is-today {
            font-weight: 900;
        }

        .t-scheduler__week-header .t-scheduler__day-header.is-selected {
            color: var(--mud-palette-primary);
            background-color: rgba(var(--mud-palette-primary-rgb), 0.1);
        }

/* Sub lines (30 min) */
.t-scheduler__sub-slot {
    flex: 1; 
    width: 100%;
    box-sizing: border-box;
    z-index: 2; 
}

    .t-scheduler__sub-slot.is-half-hour {
        border-bottom: 1px solid color-mix(in srgb, var(--mud-palette-lines-inputs), transparent 85%);
    }

.t-scheduler__grid-cell {
    padding: 0 !important;
    border-bottom: 1px solid var(--mud-palette-table-lines); 
    border-left: 1px solid var(--mud-palette-table-lines);
}


/* Scrollable Body */
.t-scheduler__week-body {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    position: relative;
    scrollbar-gutter: stable;
}

/* The Grid Lines */
.t-scheduler__time-grid {
    display: grid;
    /*grid-template-rows: repeat(24, 50px);*/ /* 50px per hour (old calc) */
    position: relative;
    width: 100%;
    height: 100%;
}

    .t-scheduler__time-grid .t-scheduler__time-label:first-child {
        display: none;
    }

    .t-scheduler__time-grid .t-scheduler__grid-cell:last-child {
        border-bottom: none !important;
        background-color: red !important;
        display: none !important;
    }

.t-scheduler__time-label {
    text-align: right;
    display: block;
    pointer-events: none;
    font-weight: 500;
    overflow: visible;
}

.t-scheduler__time-text {
    display: block;
    font-size: 11px;
    color: var(--mud-palette-text-secondary);
    text-align: center;
    position: relative;
    top: -8px;
    letter-spacing: 0.5px;
}

.t-scheduler__grid-cell {
    border-bottom: 1px solid var(--mud-palette-table-lines);
    border-left: 1px solid var(--mud-palette-table-lines);
    background: transparent;
    z-index: 0;
    cursor: pointer;
}

    .t-scheduler__grid-cell:hover {
        background-color: rgba(var(--mud-palette-primary-rgb), 0.04);
    }

/* Activity Wrapper */
.t-scheduler__activity-wrapper {
    position: relative;
    padding: 0 2px;
    box-sizing: border-box;
    pointer-events: none; /* Passthrough clicks to grid */
    transition: width 0.1s ease-out, margin-left 0.1s ease-out;
}

/* Ghost / Drag Selection */
.t-scheduler__ghost {
    height: 100%;
    width: 100%;
    background-color: rgba(var(--mud-palette-primary-rgb), 0.25);
    border: 2px dashed var(--mud-palette-primary);
    border-radius: 4px;
    color: var(--mud-palette-primary);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

/* Wrapper for the date number to allow absolute positioning inside */
.t-scheduler__date-wrapper {
    position: relative;
    display: flex; /* Flexbox to center content */
    align-items: center; /* Vertical Center */
    justify-content: center; /* Horizontal Center */
    width: 28px; /* Fixed width */
    height: 28px; /* Fixed height */
    border-radius: 50%; /* Optional: Makes hover effects round if you add them */
    flex-shrink: 0; /* Prevent squishing */
}

/* 2. The Text: Remove line-height quirks */
.t-scheduler__day-num-text {
    position: relative;
    font-size: 12px;
    z-index: 2;
    line-height: 1;
    font-weight: 500;
}

/* 3. The Overlay: Pins to the edges of the wrapper */
.t-scheduler__date-overlay {
    position: absolute;
    inset: 0; /* Shorthand for top:0; right:0; bottom:0; left:0; */
    border-radius: 50%;
    border: 2px solid var(--mud-palette-primary);
    background-color: rgba(var(--mud-palette-primary-rgb), 0.05); /* Slight fill */
    z-index: 1;
    pointer-events: none;
}

/* Drag through fixes */
.t-scheduler__week-container.is-selecting .t-scheduler__appt-block,
.t-scheduler__week-container.is-selecting .t-scheduler__appt-item {
    pointer-events: none !important;
}
.t-scheduler__week-container.is-selecting .t-scheduler__ghost {
    pointer-events: none !important;
}


/* =========================================
   5. APPOINTMENT ITEMS (Refined)
   ========================================= */

/* --- Week/Day View (Block) --- */
.t-scheduler__appt-block {
    height: 100%;
    width: 100%;
    border-radius: 4px;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 2px 6px; /* Slightly more padding for text breathing room */
    min-height: 24px;
    overflow: hidden;
    line-height: 1.2;
    transition: all 0.1s ease-in-out;
    color: var(--mud-palette-text-primary);
    font-weight: 500;
    border: 1px solid var(--mud-palette-table-lines);
}

    .t-scheduler__appt-block:hover {
        filter: brightness(0.96); /* Slight dim on hover */
        z-index: 10; /* Bring to front on hover */
    }

    .t-scheduler__appt-block:active {
        cursor: grabbing;
        opacity: 0.9;
        transform: scale(0.99);
    }

    /* NEW ACTIVITY STYLE (Week View) */
    .t-scheduler__appt-block.is-new {
        background-color: rgba(var(--mud-palette-primary-rgb), 0.15) !important;
        border: 2px dashed var(--mud-palette-primary) !important;
        color: var(--mud-palette-text-primary) !important;
        box-shadow: none;
        z-index: 50;
    }

/* --- Month View (List Item) --- */
.t-scheduler__appt-item {
    padding: 3px 6px;
    border-radius: 4px;
    /* Use mud variables for surface to handle dark mode automatically */
    background-color: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-inputs);
    cursor: grab;
    margin-bottom: 0; /* Spacing handled by flex-gap in .t-scheduler__stack */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-height: 26px;
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 500;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.15s ease;
}


    /* NEW ACTIVITY STYLE (Month View) */
    .t-scheduler__appt-item.is-new {
        background-color: rgba(var(--mud-palette-primary-rgb), 0.05) !important;
        border: 2px dashed var(--mud-palette-primary) !important;
        color: var(--mud-palette-primary) !important;
        box-shadow: none;
        font-weight: 700;
    }

        /* Ensure icon inside new item takes primary color */
        .t-scheduler__appt-item.is-new .mud-icon-root {
            color: var(--mud-palette-primary) !important;
        }

.t-scheduler__dot {
    height: 8px;
    width: 8px;
    min-width: 8px; /* Prevent squishing */
    border-radius: 50%;
    display: inline-block;
}

.t-scheduler__appt-block .t-scheduler__icon {
    fill: currentColor;
    color: inherit;
}

.t-icon-svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    /* Default size if none is set */
    font-size: 24px;
    color: inherit; /* Inherit text color */
}

    /* This targets the SVG *inside* the span */
    .t-icon-svg svg {
        /* 1em means "equal to the current font-size of the span" */
        width: 1em !important;
        height: 1em !important;
        fill: currentColor !important; /* Forces the SVG to take the text color */
    }


/* =========================================
   6. CURRENT TIME INDICATOR
   ========================================= */

.t-scheduler__now-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #ea4335; /* Google Calendar Red */
    z-index: 60; /* Higher than normal events (10/20) so it sits on top */
    pointer-events: none;
    opacity: 0.8;
}

    /* The "Lollipop" circle on the left axis */
    .t-scheduler__now-line::before {
        content: '';
        position: absolute;
        left: -5px; /* Pull it slightly into the grid line */
        top: -4px; /* Center perfectly on the 2px line */
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: #ea4335;
        box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    }

/* =========================================
   7. OVERFLOW INDICATORS (Refined Pill Style)
   ========================================= */

.t-scheduler__overflow-indicator {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center; /* Center the pill horizontally */
    z-index: 40;
    pointer-events: none; /* Allow clicks to pass through the empty space around the pill */
    padding: 4px 0; /* Breathing room from the very edge */
}

    /* Position Top */
    .t-scheduler__overflow-indicator.is-top {
        top: 0;
        /* Optional: Subtle gradient fade at the very top of the column */
        background: linear-gradient(to bottom, var(--mud-palette-surface), transparent);
    }

    /* Position Bottom */
    .t-scheduler__overflow-indicator.is-bottom {
        bottom: 0;
        /* Optional: Subtle gradient fade at the very bottom */
        background: linear-gradient(to top, var(--mud-palette-surface), transparent);
    }

/* The visual "Chip" or "Pill" */
.t-indicator-pill {
    background-color: var(--mud-palette-surface); /* Matches theme background */
    border: 1px solid var(--mud-palette-table-lines);
    border-radius: 12px; /* Fully rounded capsule */
    padding: 2px 8px;
    /* Typography */
    font-size: 10px;
    font-weight: 700;
    color: var(--mud-palette-text-secondary);
    line-height: 1;
    /* Layout */
    display: flex;
    align-items: center;
    gap: 2px;
    /* Interactions */
    cursor: help;
    pointer-events: auto; /* Re-enable mouse interaction for just the pill */
    box-shadow: 0 2px 5px rgba(0,0,0,0.15); /* Pop it off the background */
    transition: all 0.2s ease;
}


    /* Icon styling adjustments */
    .t-indicator-pill .indicator-icon {
        font-size: 14px !important;
        margin-left: -2px; /* Pull icon slightly closer to edge */
    }

/* Dark Mode specific tweak (Optional: adds a slight glow) */
@media (prefers-color-scheme: dark) {
    .t-indicator-pill {
        background-color: rgba(30, 30, 30, 0.8); /* Semi-transparent background */
        backdrop-filter: blur(4px); /* Blur the events passing behind it */
    }
}

/* =========================================
   8. DRAG & DROP INTERACTION FIXES
   ========================================= */

.t-scheduler__week-container.is-dragging-active .t-scheduler__appt-block,
.t-scheduler__week-container.is-dragging-active .t-scheduler__activity-wrapper,
.t-scheduler__week-container.is-dragging-active .t-scheduler__appt-item {
    pointer-events: none !important;
    transition: all 0.1s ease;
    opacity: 0.75; 
}
    .t-scheduler__week-container.is-dragging-active .t-scheduler__appt-block.is-ghost-shadow {
        opacity: 1 !important; 
        z-index: 100; 
        box-shadow: 0 10px 20px rgba(0,0,0,0.3); 
        border: 2px solid var(--mud-palette-primary) !important;
        background-color: var(--mud-palette-surface) !important;
    }


