/* ============================================================================
   Calendar Page Styles
   BEM Naming: calendar-page, calendar-grid, calendar-week, calendar-day
   ============================================================================ */

/* Page Container */
.calendar-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--color-bg);
}

/* Header */
.calendar-page__header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-card-bg);
}

.calendar-page__title {
    margin: 0;
    font-size: var(--font-size-2xl);
    font-weight: 600;
    color: var(--color-text);
}

.calendar-page__controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.calendar-page__nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.calendar-page__nav-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-card-bg);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.calendar-page__nav-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.calendar-page__today-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-card-bg);
    color: var(--color-text);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.calendar-page__today-btn:hover {
    background: var(--color-surface-hover);
}

.calendar-page__month-title {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text);
    min-width: 200px;
}

.calendar-page__view-toggle {
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.calendar-page__view-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background: var(--color-card-bg);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.calendar-page__view-btn:not(:last-child) {
    border-right: 1px solid var(--color-border);
}

.calendar-page__view-btn:hover {
    background: var(--color-surface-hover);
}

.calendar-page__view-btn--active {
    background: var(--color-primary);
    color: white;
}

.calendar-page__view-btn--active:hover {
    background: var(--color-primary-hover);
}

.calendar-page__add-btn {
    margin-left: auto;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: white;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: background var(--transition-fast);
}

.calendar-page__add-btn:hover {
    background: var(--color-primary-hover);
}

/* Body */
.calendar-page__body {
    flex: 1;
    overflow: auto;
    padding: var(--spacing-md);
}

.calendar-page__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: var(--spacing-md);
    color: var(--color-text-secondary);
}

.calendar-page__loading i {
    font-size: 2rem;
}

/* Month Grid */
.calendar-grid {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.calendar-grid__header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-bottom: 1px solid var(--color-border);
}

.calendar-grid__day-name {
    padding: var(--spacing-sm);
    text-align: center;
    font-weight: 600;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    color: var(--color-text-secondary);
    min-width: 0;
}

.calendar-grid__body {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: 1fr;
}

.calendar-grid__cell {
    min-height: 100px;
    min-width: 0;
    padding: var(--spacing-sm);
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background var(--transition-fast);
    overflow: hidden;
}

.calendar-grid__cell:hover {
    background: var(--color-surface-hover);
}

.calendar-grid__cell:nth-child(7n) {
    border-right: none;
}

.calendar-grid__cell--other-month {
    background: var(--color-surface);
}

.calendar-grid__cell--other-month .calendar-grid__date {
    color: var(--color-text-muted);
}

.calendar-grid__cell--today {
    background: var(--color-primary-bg);
}

.calendar-grid__cell--today .calendar-grid__date {
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-grid__date {
    font-weight: 500;
    font-size: var(--font-size-sm);
    color: var(--color-text);
    margin-bottom: var(--spacing-xs);
}

.calendar-grid__events {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calendar-grid__event {
    padding: 2px 4px;
    font-size: 0.7rem;
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-grid__event-time {
    font-weight: 600;
    margin-right: 4px;
}

.calendar-grid__more {
    font-size: 0.7rem;
    color: var(--color-text-secondary);
    padding: 2px 4px;
}

/* Week View */
.calendar-week {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.calendar-week__header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-bottom: 1px solid var(--color-border);
}

.calendar-week__day-header {
    padding: var(--spacing-sm);
    text-align: center;
    border-right: 1px solid var(--color-border);
    min-width: 0;
}

.calendar-week__day-header:last-child {
    border-right: none;
}

.calendar-week__day-header--today {
    background: var(--color-primary-bg);
}

.calendar-week__day-name {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-xs);
}

.calendar-week__day-number {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text);
}

.calendar-week__day-header--today .calendar-week__day-number {
    color: var(--color-primary);
}

.calendar-week__body {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    overflow-y: auto;
}

.calendar-week__day {
    min-height: 300px;
    min-width: 0;
    padding: var(--spacing-sm);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    overflow: hidden;
}

.calendar-week__day:last-child {
    border-right: none;
}

.calendar-week__day--today {
    background: var(--color-primary-bg);
}

.calendar-week__event {
    padding: var(--spacing-sm);
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.calendar-week__event-time {
    font-size: 0.7rem;
    opacity: 0.9;
    margin-bottom: 2px;
}

.calendar-week__event-title {
    font-weight: 500;
}

/* Day View */
.calendar-day {
    max-width: 800px;
    margin: 0 auto;
}

.calendar-day__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    color: var(--color-text-secondary);
    text-align: center;
}

.calendar-day__empty i {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    color: var(--color-text-muted);
}

.calendar-day__events {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.calendar-day__event {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-lg);
}

.calendar-day__event-time {
    min-width: 100px;
    font-weight: 500;
    color: var(--color-primary);
    font-size: var(--font-size-sm);
}

.calendar-day__event-content {
    flex: 1;
}

.calendar-day__event-title {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--spacing-xs);
}

.calendar-day__event-desc {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-sm);
}

.calendar-day__event-location {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.calendar-day__event-location i {
    margin-right: var(--spacing-xs);
}

.calendar-day__event-link {
    color: var(--color-text-muted);
    font-size: 1rem;
    transition: color var(--transition-fast);
}

.calendar-day__event-link:hover {
    color: var(--color-primary);
}

/* Modal Styles */
.calendar-modal {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.calendar-modal__field {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.calendar-modal__label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
}

.calendar-modal__input,
.calendar-modal__textarea {
    padding: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    background: var(--color-input-bg);
    color: var(--color-input-text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.calendar-modal__input:focus,
.calendar-modal__textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
}

.calendar-modal__textarea {
    min-height: 80px;
    resize: vertical;
}

.calendar-modal__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.calendar-modal__checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
}

.calendar-modal__checkbox-label input {
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .calendar-page__controls {
        flex-direction: column;
        align-items: stretch;
    }

    .calendar-page__nav {
        justify-content: center;
    }

    .calendar-page__month-title {
        text-align: center;
    }

    .calendar-page__view-toggle {
        justify-content: center;
    }

    .calendar-page__add-btn {
        margin-left: 0;
        justify-content: center;
    }

    .calendar-grid__cell {
        min-height: 60px;
        padding: 0.25rem;
    }

    .calendar-grid__event {
        font-size: 0.6rem;
    }

    .calendar-modal__row {
        grid-template-columns: 1fr;
    }
}
