/* ==========================================================================
   Calendar Day Corner Hover Menu Styles
   ========================================================================== */

/* Day Cell Relative Positioning Anchor */
.calendar-day,
.calendar-day-cell,
.calendar-day-mini {
    position: relative !important;
}

/* Day Menu Corner Trigger Button */
.calendar-day-menu-trigger {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--pico-muted-color, #94a3b8);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                background 0.15s ease,
                color 0.15s ease,
                transform 0.15s ease;
    z-index: 25;
    padding: 0;
    margin: 0;
    outline: none;
    line-height: 1;
    font-size: 14px;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.calendar-day-menu-trigger::before {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    bottom: -8px;
    left: -8px;
}

/* Light Mode Overrides */
[data-theme="light"] .calendar-day-menu-trigger {
    background: rgba(241, 245, 249, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: #475569;
}

/* Hover over cell or hover/focus on trigger reveals the button */
.calendar-day:hover .calendar-day-menu-trigger,
.calendar-day-cell:hover .calendar-day-menu-trigger,
.calendar-day-mini:hover .calendar-day-menu-trigger,
.calendar-day-menu-trigger:hover,
.calendar-day-menu-trigger:focus-visible,
.calendar-day-menu-trigger.active {
    opacity: 1 !important;
    visibility: visible !important;
}

@media (hover: none), (max-width: 992px) {
    .calendar-day-menu-trigger,
    .calendar-item-menu-trigger {
        opacity: 0.85 !important;
        visibility: visible !important;
    }
}

html.mobile-device .calendar-day-menu-trigger,
html.mobile-device .calendar-item-menu-trigger {
    opacity: 0.85 !important;
    visibility: visible !important;
}

html.mobile-device #cdm-clipboard-floating-bar {
    bottom: 80px;
}

.calendar-day-menu-trigger:hover,
.calendar-day-menu-trigger.active {
    background: var(--pico-primary, #6366f1) !important;
    border-color: var(--pico-primary, #6366f1) !important;
    color: #ffffff !important;
    transform: scale(1.08);
}

/* Dropdown Menu Container */
.calendar-day-dropdown-menu {
    position: absolute;
    top: 28px;
    right: 4px;
    width: 220px;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 14px 35px -4px rgba(0, 0, 0, 0.55), 0 6px 14px -3px rgba(0, 0, 0, 0.35);
    z-index: 1000;
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    font-family: inherit;
    font-size: 0.82rem;
    color: #e2e8f0;
    text-align: left;
    user-select: none;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    animation: cdmDropdownFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="light"] .calendar-day-dropdown-menu {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(203, 213, 225, 0.8);
    box-shadow: 0 14px 30px -4px rgba(0, 0, 0, 0.18), 0 4px 10px -2px rgba(0, 0, 0, 0.08);
    color: #1e293b;
}

@keyframes cdmDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header inside dropdown */
.cdm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
}

[data-theme="light"] .cdm-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    color: #64748b;
}

.cdm-header .cdm-date-label {
    color: var(--pico-primary, #6366f1);
}

.cdm-header .cdm-count-badge {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.68rem;
}

[data-theme="light"] .cdm-header .cdm-count-badge {
    background: rgba(0, 0, 0, 0.06);
    color: #475569;
}

/* Menu Items */
.cdm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s ease, color 0.12s ease, transform 0.1s ease;
    text-decoration: none;
}

.cdm-item:hover:not(.disabled) {
    background: rgba(99, 102, 241, 0.15);
    color: var(--pico-primary, #818cf8);
    transform: translateX(2px);
}

[data-theme="light"] .cdm-item:hover:not(.disabled) {
    background: rgba(99, 102, 241, 0.1);
    color: #4f46e5;
}

.cdm-item .cdm-icon {
    font-size: 0.95rem;
    width: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cdm-item .cdm-label {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cdm-item .cdm-subtext {
    font-size: 0.68rem;
    opacity: 0.65;
    margin-left: auto;
}

/* Disabled menu item */
.cdm-item.disabled {
    opacity: 0.38;
    cursor: not-allowed;
    filter: grayscale(1);
}

/* Destructive action styling */
.cdm-item.destructive:hover:not(.disabled) {
    background: rgba(239, 68, 68, 0.18);
    color: #ef4444;
}

/* Active Paste Item Highlight */
.cdm-item.paste-active {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    font-weight: 600;
}

.cdm-item.paste-active:hover {
    background: rgba(16, 185, 129, 0.22);
}

/* Visual cut indicator on cells */
.calendar-item-cut {
    border: 2px dashed #f59e0b !important;
    opacity: 0.55 !important;
    animation: cdmPulseDashed 1.6s infinite ease-in-out;
}

@keyframes cdmPulseDashed {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 0.25; }
}

/* Universal Floating Toast for Calendar Clipboard */
#cdm-clipboard-floating-bar {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(99, 102, 241, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9999;
    font-size: 0.85rem;
    color: #f8fafc;
    animation: cdmSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="light"] #cdm-clipboard-floating-bar {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #0f172a;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

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

/* Calendar Day Menu Selection Modal */
.cdm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: cdmFadeIn 0.15s ease forwards;
}

.cdm-modal-card {
    background: var(--pico-card-background-color, #1e293b);
    border: 1px solid var(--pico-muted-border-color, rgba(255,255,255,0.15));
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    padding: 1.5rem;
    color: var(--pico-color, #e2e8f0);
}

@keyframes cdmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================================================
   Calendar Individual Item Menu Styles
   ========================================================================== */

/* Anchor relative positioning for items */
.calendar-event,
.calendar-event-mini,
.scheduled-workout-item,
.calendar-workout-item {
    position: relative !important;
}

/* Item Trigger Button (⋮) */
.calendar-item-menu-trigger {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, background 0.15s ease, transform 0.15s ease;
    z-index: 20;
    padding: 0;
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    user-select: none;
}

/* Light mode trigger */
[data-theme="light"] .calendar-item-menu-trigger {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.5);
    color: #334155;
}

/* Reveal trigger on item hover or when active */
.calendar-event:hover .calendar-item-menu-trigger,
.calendar-event-mini:hover .calendar-item-menu-trigger,
.scheduled-workout-item:hover .calendar-item-menu-trigger,
.calendar-workout-item:hover .calendar-item-menu-trigger,
.calendar-item-menu-trigger:hover,
.calendar-item-menu-trigger:focus-visible,
.calendar-item-menu-trigger.active {
    opacity: 1 !important;
    visibility: visible !important;
}

.calendar-item-menu-trigger:hover,
.calendar-item-menu-trigger.active {
    background: var(--pico-primary, #6366f1) !important;
    border-color: var(--pico-primary, #6366f1) !important;
    color: #ffffff !important;
    transform: scale(1.12);
}

/* Fixed-position Item Dropdown Menu (immune to overflow clipping) */
.calendar-item-dropdown-menu {
    position: fixed;
    width: 220px;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    box-shadow: 0 16px 38px -4px rgba(0, 0, 0, 0.6), 0 6px 16px -2px rgba(0, 0, 0, 0.4);
    z-index: 100050;
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    font-family: inherit;
    font-size: 0.82rem;
    color: #e2e8f0;
    text-align: left;
    user-select: none;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    animation: cdmDropdownFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="light"] .calendar-item-dropdown-menu {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(203, 213, 225, 0.85);
    box-shadow: 0 16px 32px -4px rgba(0, 0, 0, 0.18), 0 4px 12px -2px rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

/* Item Header inside dropdown */
.cim-header {
    display: flex;
    flex-direction: column;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 3px;
}

[data-theme="light"] .cim-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.cim-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

.cim-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #f8fafc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-theme="light"] .cim-title {
    color: #0f172a;
}

.cim-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.2);
    color: var(--pico-primary, #818cf8);
    text-transform: capitalize;
    flex-shrink: 0;
}

.cim-meta {
    font-size: 0.70rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
}

[data-theme="light"] .cim-meta {
    color: #64748b;
}

