/**
 * Nextcloud Calendar — Frontend Styles
 *
 * Visual style closely matches the Nextcloud Calendar app:
 * light-grey borders, rounded events, clean buttons.
 * Includes styles for both calendar view and events list.
 */

/* ================================================================== */
/*  Calendar wrapper                                                  */
/* ================================================================== */
#nc-calendar-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #222;
}

/* ================================================================== */
/*  FullCalendar overrides — Nextcloud look                           */
/* ================================================================== */

/* Toolbar */
#nc-calendar .fc-toolbar {
    margin-bottom: 16px;
}

#nc-calendar .fc-toolbar-title {
    font-size: 1.3em;
    font-weight: 600;
    color: #222;
}

/* Buttons */
#nc-calendar .fc-button {
    background-color: #fff;
    border: 1px solid #dbdbdb;
    color: #222;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 4px;
    text-transform: none;
    box-shadow: none;
    transition: background-color 0.15s, border-color 0.15s;
}

#nc-calendar .fc-button:hover {
    background-color: #f5f5f5;
    border-color: #ccc;
}

#nc-calendar .fc-button-active,
#nc-calendar .fc-button:active {
    background-color: var(--nc-accent, #0082c9) !important;
    border-color: var(--nc-accent, #0082c9) !important;
    color: #fff !important;
}

#nc-calendar .fc-button-primary:not(:disabled).fc-button-active {
    background-color: var(--nc-accent, #0082c9);
    border-color: var(--nc-accent, #0082c9);
    color: #fff;
}

/* Today button */
#nc-calendar .fc-today-button {
    background-color: var(--nc-accent, #0082c9);
    border-color: var(--nc-accent, #0082c9);
    color: #fff;
}

#nc-calendar .fc-today-button:hover {
    background-color: var(--nc-accent-hover, #006ba1);
    border-color: var(--nc-accent-hover, #006ba1);
}

#nc-calendar .fc-today-button:disabled {
    opacity: 0.5;
}

/* Grid borders */
#nc-calendar .fc-scrollgrid {
    border-color: #e0e0e0;
}

#nc-calendar .fc th,
#nc-calendar .fc td {
    border-color: #e0e0e0;
}

#nc-calendar .fc-col-header-cell {
    background-color: #fafafa;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: #555;
    padding: 8px 0;
}

/* Today highlight */
#nc-calendar .fc-day-today {
    background-color: rgba(0, 130, 201, 0.04) !important;
}

/* ================================================================== */
/*  Events                                                            */
/* ================================================================== */
#nc-calendar .fc-event {
    border: none;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    transition: opacity 0.15s;
}

#nc-calendar .fc-event:hover {
    opacity: 0.85;
}

#nc-calendar .fc-daygrid-event-dot {
    border-radius: 50%;
}

#nc-calendar .fc-event-title {
    font-weight: 500;
}

#nc-calendar .fc-event-time {
    font-weight: 400;
    opacity: 0.85;
}

/* Multi-day events in month view */
#nc-calendar .fc-daygrid-event {
    border-radius: 4px;
    margin: 1px 2px;
}

/* ================================================================== */
/*  Time grid (week/day) — slot styling                               */
/* ================================================================== */
#nc-calendar .fc .fc-timegrid-axis,
#nc-calendar .fc .fc-timegrid-axis-frame {
    width: 92px;
    min-width: 92px;
}

#nc-calendar .fc .fc-timegrid-axis-cushion {
    white-space: nowrap;
    font-size: 12px;
}

#nc-calendar .fc-timegrid-slot {
    height: 2.5em;
}

#nc-calendar .fc-timegrid-slot-label {
    font-size: 12px;
    color: #666;
}

#nc-calendar .fc-timegrid-now-indicator-line {
    border-color: #e53935;
}

#nc-calendar .fc-timegrid-now-indicator-arrow {
    border-color: #e53935;
}

/* ================================================================== */
/*  Modal (<dialog>)                                                  */
/* ================================================================== */
.nc-modal {
    border: none !important;
    border-radius: 16px;
    padding: 0;
    max-width: 70% !important;
    width: 70% !important;
    min-width: 280px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
    position: fixed;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    z-index: 100000;
    max-height: 95vh;
    overflow-y: auto;
    background: #fff;
    margin: 0 !important;
}

.nc-modal::backdrop {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
}

.nc-modal__inner {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    position: relative;
    min-height: 180px;
}

.nc-modal__inner--no-image {
    display: block;
}

/* Close button */
.nc-modal__close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    z-index: 2;
}

.nc-modal__close:hover {
    background-color: rgba(0, 0, 0, 0.65);
}

.nc-modal__inner--no-image .nc-modal__close {
    background: rgba(0, 0, 0, 0.08);
    color: #333;
}

.nc-modal__inner--no-image .nc-modal__close:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* Image — колонка слева, 1/3 ширины */
.nc-modal__image {
    flex: 0 0 33.33%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f5f5f5;
    border-radius: 16px 0 0 16px;
    padding: 12px;
    box-sizing: border-box;
}

.nc-modal__image img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    display: block;
    border-radius: 8px;
}

.nc-modal__image:empty {
    display: none;
}

/* Контентная часть — правая колонка */
.nc-modal__body {
    flex: 1;
    padding: 24px 44px 24px 22px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.nc-modal__inner--no-image .nc-modal__body {
    padding: 28px 48px 28px 28px;
}

/* Title */
.nc-modal__title {
    font-size: 1.4em;
    font-weight: 700;
    margin: 0 0 10px;
    color: #111;
    line-height: 1.3;
}

/* Date/time */
.nc-modal__datetime {
    font-size: 15px;
    font-weight: 600;
    color: var(--nc-accent, #0082c9);
    margin: 0 0 10px;
}

/* Location */
.nc-modal__location {
    font-size: 15px;
    color: #555;
    margin: 0 0 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.nc-modal__location:empty {
    display: none;
}

.nc-modal__location a {
    color: var(--nc-accent, #0082c9);
    text-decoration: none;
}

.nc-modal__location a:hover {
    text-decoration: underline;
}

/* Description */
.nc-modal__description {
    font-size: 15px;
    line-height: 1.65;
    color: #444;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}

.nc-modal__description:empty {
    display: none;
}

.nc-modal__description a {
    color: var(--nc-accent, #0082c9);
    text-decoration: none;
}

.nc-modal__description a:hover {
    text-decoration: underline;
}

/* Мобильный */
@media (max-width: 540px) {
    .nc-modal {
        width: 98%;
        border-radius: 12px;
        max-height: 95vh;
    }

    .nc-modal__inner {
        flex-direction: column;
    }

    .nc-modal__image {
        flex: none;
        width: 100%;
        border-radius: 12px 12px 0 0;
        padding: 16px 16px 0;
        background: #f5f5f5;
    }

    .nc-modal__image img {
        max-height: 180px;
        margin: 0 auto;
    }

    .nc-modal__body {
        padding: 16px 40px 20px 16px;
    }
}
/* ================================================================== */
/*  Events List — [nextcloud_events]                                  */
/* ================================================================== */
.nc-events-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #222;
}

.nc-events-title {
    font-size: 1.4em;
    font-weight: 600;
    color: #222;
    margin: 0 0 16px;
    text-align: center;
}

/* Loading spinner */
.nc-events-loading {
    text-align: center;
    padding: 32px 16px;
    color: #888;
    font-size: 14px;
}

.nc-events-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-top-color: var(--nc-accent, #0082c9);
    border-radius: 50%;
    animation: nc-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes nc-spin {
    to { transform: rotate(360deg); }
}

/* Empty state */
.nc-events-empty {
    text-align: center;
    padding: 32px 16px;
    color: #888;
    font-size: 14px;
}

/* ================================================================== */
/*  Event Card                                                        */
/* ================================================================== */
.nc-event-card {
    display: flex;
    align-items: flex-start;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.nc-event-card:hover {
    border-color: #ccc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Today highlight */
.nc-event-card--today {
    border-left: 4px solid var(--nc-accent, #0082c9);
    background-color: #f8fbff;
}

/* Image thumbnail */
.nc-event-card__image {
    flex: 0 0 100px;
    min-height: 80px;
    overflow: hidden;
    background: #f0f0f0;
}

.nc-event-card__image img {
    width: 100px;
    height: 80px;
    object-fit: cover;
    display: block;
}

/* Content area */
.nc-event-card__content {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
}

/* Header row */
.nc-event-card__header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Color dot */
.nc-event-card__color {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Date */
.nc-event-card__date {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    min-width: 70px;
}

/* Time */
.nc-event-card__time {
    color: #666;
    white-space: nowrap;
    min-width: 100px;
}

/* Title */
.nc-event-card__title {
    font-weight: 600;
    color: #222;
    flex: 1;
    min-width: 120px;
}

/* Toggle button */
.nc-event-card__toggle {
    padding: 4px 12px;
    background: var(--nc-accent, #0082c9);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: background-color 0.15s;
    flex-shrink: 0;
}

.nc-event-card__toggle:hover {
    background: var(--nc-accent-hover, #006ba1);
}

/* Expandable details */
.nc-event-card__details {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.nc-event-card__location {
    font-size: 13px;
    color: #555;
    margin: 0 0 6px;
}

.nc-event-card__location a {
    color: var(--nc-accent, #0082c9);
    text-decoration: none;
}

.nc-event-card__location a:hover {
    text-decoration: underline;
}

.nc-event-card__description {
    font-size: 13px;
    line-height: 1.5;
    color: #444;
}

.nc-event-card__description a {
    color: var(--nc-accent, #0082c9);
    text-decoration: none;
}

.nc-event-card__description a:hover {
    text-decoration: underline;
}

/* ================================================================== */
/*  Responsive                                                        */
/* ================================================================== */
@media (max-width: 768px) {
    #nc-calendar-wrap {
        padding: 8px;
    }

    #nc-calendar .fc-toolbar {
        flex-direction: column;
        gap: 8px;
    }

    #nc-calendar .fc-toolbar-title {
        font-size: 1.1em;
    }

    .nc-modal {
        width: 95%;
        max-width: none;
    }

    .nc-modal__inner {
        padding: 16px;
    }

    /* Events list responsive */
    .nc-events-wrap {
        padding: 8px;
    }

    .nc-event-card {
        flex-direction: column;
    }

    .nc-event-card__image {
        flex: none;
        width: 100%;
        min-height: 0;
    }

    .nc-event-card__image img {
        width: 100%;
        height: 160px;
        object-fit: cover;
    }

    .nc-event-card__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .nc-event-card__date,
    .nc-event-card__time {
        min-width: 0;
    }

    .nc-event-card__title {
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .nc-event-card__content {
        padding: 10px 12px;
    }

    .nc-event-card__toggle {
        width: 100%;
        text-align: center;
        margin-top: 4px;
    }
}
