/**
 * Tebuto page-specific layouts and full-height admin shell.
 *
 * @package Tebuto
 */

/* ==========================================================================
   Full-height shell — keyed off body.tebuto-fullheight
   ========================================================================== */

@media (min-width: 783px) {
    body.tebuto-fullheight {
        overflow: hidden;
    }

    body.tebuto-fullheight #wpfooter {
        display: none;
    }

    body.tebuto-fullheight #wpcontent,
    body.tebuto-fullheight #wpbody {
        height: calc(100vh - 32px);
        overflow: hidden;
        box-sizing: border-box;
    }

    body.tebuto-fullheight #wpbody-content {
        display: flex;
        flex-direction: column;
        float: none;
        width: auto;
        box-sizing: border-box;
        height: 100%;
        max-height: 100%;
        padding-bottom: 16px;
        overflow: hidden;
    }

    body.tebuto-fullheight #wpbody-content > .notice,
    body.tebuto-fullheight #wpbody-content > .updated,
    body.tebuto-fullheight #wpbody-content > .error {
        flex-shrink: 0;
    }

    body.tebuto-fullheight .tebuto-admin-wrap {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        height: auto;
        margin-top: 16px;
        margin-bottom: 0;
        overflow: hidden;
        box-sizing: border-box;
    }

    body.tebuto-fullheight .tebuto-admin-wrap > .tebuto-header {
        flex-shrink: 0;
    }

    /* Dashboard: stats fixed, cards fill remaining height and scroll inside */
    body.tebuto-fullheight .tebuto-page-dashboard .tebuto-stats-grid {
        flex-shrink: 0;
    }

    body.tebuto-fullheight .tebuto-page-dashboard .tebuto-dashboard-grid {
        display: grid;
        flex: 1 1 auto;
        min-height: 0;
        align-items: stretch;
        grid-template-rows: minmax(0, 1fr);
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-dashboard .tebuto-dashboard-grid > .tebuto-card {
        display: flex;
        flex-direction: column;
        min-height: 0;
        height: 100%;
        max-height: 100%;
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-dashboard .tebuto-dashboard-grid .tebuto-card-header {
        flex-shrink: 0;
    }

    body.tebuto-fullheight .tebuto-page-dashboard .tebuto-dashboard-grid .tebuto-card-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
    }

    /* Occurrence detail: meta/summary fixed, Teilnehmer + Termine fill and scroll inside */
    body.tebuto-fullheight .tebuto-page-occurrence > .tebuto-occurrence-settings-summary,
    body.tebuto-fullheight .tebuto-page-occurrence > .tebuto-admonition,
    body.tebuto-fullheight .tebuto-page-occurrence > .tebuto-auth-notice {
        flex-shrink: 0;
    }

    body.tebuto-fullheight .tebuto-page-occurrence .tebuto-occurrence-grid {
        display: grid;
        flex: 1 1 auto;
        min-height: 0;
        align-items: stretch;
        grid-template-rows: minmax(0, 1fr);
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-occurrence .tebuto-occurrence-grid > .tebuto-card {
        display: flex;
        flex-direction: column;
        min-height: 0;
        height: 100%;
        max-height: 100%;
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-occurrence .tebuto-occurrence-grid .tebuto-card-header {
        flex-shrink: 0;
    }

    body.tebuto-fullheight .tebuto-page-occurrence .tebuto-occurrence-grid .tebuto-card-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
    }

    @media (max-width: 1099px) {
        body.tebuto-fullheight .tebuto-page-occurrence .tebuto-occurrence-grid {
            grid-template-rows: none;
            grid-auto-rows: minmax(0, 1fr);
        }
    }

    /* Categories / bookings / seminars: sticky thead table scroll */
    body.tebuto-fullheight .tebuto-page-categories > .tebuto-card,
    body.tebuto-fullheight .tebuto-page-bookings > .tebuto-card,
    body.tebuto-fullheight .tebuto-page-seminars > .tebuto-card {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-bookings > .tebuto-filters-panel {
        flex-shrink: 0;
    }

    body.tebuto-fullheight .tebuto-page-categories .tebuto-table-responsive,
    body.tebuto-fullheight .tebuto-page-bookings .tebuto-table-responsive,
    body.tebuto-fullheight .tebuto-page-seminars .tebuto-accordion {
        flex: 1;
        min-height: 0;
        overflow: auto;
        margin: 0;
        padding: 0;
    }

    body.tebuto-fullheight .tebuto-page-categories .tebuto-table thead th,
    body.tebuto-fullheight .tebuto-page-bookings .tebuto-table thead th {
        position: sticky;
        top: 0;
        z-index: 1;
    }

    /* Shortcode: settings column scrolls, preview pinned */
    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-widget-editor-layout {
        flex: 1;
        min-height: 0;
        align-items: stretch;
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-widget-settings-column {
        min-height: 0;
        overflow-y: auto;
        padding-right: 4px;
    }

    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-widget-preview-column {
        position: static;
        top: auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-widget-preview-column > .tebuto-card {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-shortcode #tebuto-widget-preview-container {
        flex: 1;
        min-height: 0;
        overflow: auto;
    }

    body.tebuto-fullheight .tebuto-page-shortcode #tebuto-widget-settings-form {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-widget-settings-app {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-widget-settings-layout {
        display: grid;
        grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        align-items: stretch;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-widget-settings-controls {
        display: flex;
        flex-direction: column;
        min-height: 0;
        min-width: 0;
        overflow: hidden;
        padding-right: 4px;
    }

    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-widget-settings-controls-scroll {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
    }

    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-widget-variant-tabs {
        flex-shrink: 0;
    }

    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-widget-settings-preview {
        min-height: 0;
        min-width: 0;
        overflow: auto;
    }

    body.tebuto-fullheight .tebuto-page-shortcode .tebuto-form-actions {
        flex-shrink: 0;
        padding-top: 12px;
    }
}

/* ==========================================================================
   Dashboard
   ========================================================================== */

.tebuto-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

@media (max-width: 1200px) {
    .tebuto-dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 783px) and (max-width: 1200px) {
    body.tebuto-fullheight .tebuto-page-dashboard .tebuto-dashboard-grid {
        grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    }
}

/* ==========================================================================
   Shortcode / Widget Editor
   ========================================================================== */

.tebuto-widget-editor-layout {
    display: grid;
    grid-template-columns: minmax(380px, 480px) 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1200px) {
    .tebuto-widget-editor-layout {
        grid-template-columns: 1fr;
    }

    .tebuto-widget-preview-column {
        order: -1;
    }
}

.tebuto-widget-settings-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tebuto-widget-preview-column {
    position: sticky;
    top: 32px;
}

.tebuto-preview-header {
    margin-bottom: 16px;
}

.tebuto-preview-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--tebuto-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#tebuto-widget-preview-container {
    min-height: 500px;
}

#tebuto-widget-preview-container #tebuto-booking-widget {
    max-width: 100%;
}

.tebuto-form-section {
    margin-bottom: 28px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--tebuto-border-light);
}

.tebuto-form-section:last-of-type {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.tebuto-form-section-title {
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--tebuto-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tebuto-theme-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tebuto-preset-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--tebuto-bg);
    border: 2px solid var(--tebuto-border);
    border-radius: var(--tebuto-radius-sm);
    cursor: pointer;
    transition: all var(--tebuto-transition);
}

.tebuto-preset-btn:hover {
    border-color: var(--tebuto-primary-brand);
    background: var(--tebuto-white);
}

.tebuto-preset-btn.active {
    border-color: var(--tebuto-primary-brand);
    background: var(--tebuto-primary-subtle);
}

.tebuto-preset-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.tebuto-preset-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--tebuto-text);
}

.tebuto-color-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 500px) {
    .tebuto-color-grid {
        grid-template-columns: 1fr;
    }
}

.tebuto-color-grid .tebuto-form-group {
    margin-bottom: 0;
}

.tebuto-category-selection-first-option {
    margin-bottom: 16px;
}

.tebuto-categories-multiselect {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--tebuto-border);
    border-radius: var(--tebuto-radius-sm);
    background: var(--tebuto-white);
}

.tebuto-loading-categories {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    color: var(--tebuto-text-secondary);
}

.tebuto-loading-categories .spinner {
    float: none;
    margin: 0;
}

.tebuto-category-checkboxes {
    padding: 8px 0;
}

.tebuto-category-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background var(--tebuto-transition);
}

.tebuto-category-checkbox:hover {
    background: var(--tebuto-bg);
}

.tebuto-category-checkbox--unavailable {
    opacity: 0.55;
    cursor: not-allowed;
}

.tebuto-category-checkbox--unavailable:hover {
    background: transparent;
}

.tebuto-category-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
}

.tebuto-category-checkbox .tebuto-category-name {
    font-size: 14px;
    color: var(--tebuto-text);
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    font-weight: 400;
}

#custom_css {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
}

/* ==========================================================================
   Seminars admin
   ========================================================================== */

.tebuto-page-seminars .tebuto-seminars-card {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.tebuto-accordion {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.tebuto-accordion-item {
    border-bottom: 1px solid var(--tebuto-border, #e5e7eb);
}

.tebuto-accordion-item:last-child {
    border-bottom: none;
}

.tebuto-accordion-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.tebuto-accordion-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    text-align: left;
    cursor: pointer;
    color: inherit;
}

.tebuto-accordion-chevron {
    transition: transform 0.15s ease;
    color: var(--tebuto-text-secondary, #6b7280);
}

.tebuto-accordion-item.is-open .tebuto-accordion-chevron {
    transform: rotate(90deg);
}

.tebuto-accordion-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.tebuto-accordion-title strong {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--tebuto-text, #111827);
}

.tebuto-accordion-meta {
    margin-left: auto;
    color: var(--tebuto-text-secondary, #6b7280);
    white-space: nowrap;
    font-size: 13px;
}

.tebuto-accordion-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tebuto-inline-form {
    display: inline;
    margin: 0;
}

.tebuto-accordion-body {
    padding: 0 16px 16px 52px;
}

.tebuto-accordion-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--tebuto-text-secondary, #6b7280);
    padding: 8px 0;
}

.tebuto-accordion-footer,
.tebuto-accordion-empty {
    padding-top: 12px;
}

.tebuto-occurrences-table .tebuto-actions-col {
    width: 1%;
    white-space: nowrap;
    vertical-align: middle;
}

.tebuto-occurrences-table .tebuto-action-buttons {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
}

.tebuto-occurrences-table .tebuto-action-buttons .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    flex-shrink: 0;
}

.tebuto-occurrences-table .tebuto-action-buttons .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1.2;
}

.tebuto-past-occurrences {
    margin-top: 16px;
    padding-top: 4px;
}

.tebuto-past-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    margin: 0;
    border: 0;
    background: transparent;
    color: var(--tebuto-text-secondary, #6b7280);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.4;
}

.tebuto-past-toggle:hover {
    color: var(--tebuto-text, #111827);
}

.tebuto-past-chevron {
    font-size: 14px;
    width: 14px;
    height: 14px;
    transition: transform 0.15s ease;
}

.tebuto-past-occurrences.is-open .tebuto-past-chevron {
    transform: rotate(90deg);
}

.tebuto-past-count {
    font-weight: 400;
    opacity: 0.8;
}

.tebuto-past-body {
    margin-top: 8px;
    opacity: 0.85;
}

.tebuto-past-body .tebuto-occurrences-table--past {
    font-size: 13px;
}

.tebuto-past-footer {
    display: flex;
    justify-content: center;
    padding: 8px 0 4px;
}

.tebuto-past-show-more {
    font-size: 13px;
}

.tebuto-seminar-banner-preview {
    margin-top: 8px;
}

.tebuto-seminar-banner-preview img {
    max-width: 240px;
    max-height: 120px;
    border-radius: 8px;
    object-fit: cover;
}

.tebuto-occurrence-address {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0;
}

.tebuto-occurrence-address[hidden] {
    display: none !important;
}

.tebuto-page-occurrence .tebuto-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.tebuto-page-occurrence .tebuto-header-title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.tebuto-occurrence-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 0;
}

.tebuto-occurrence-subtitle {
    color: var(--tebuto-text-secondary, #6b7280);
    font-size: 14px;
}

.tebuto-occurrence-seminar-name {
    color: var(--tebuto-text-secondary, #6b7280);
    font-size: 14px;
}

.tebuto-occurrence-settings-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 20px;
    margin: 0 0 24px;
    padding: 0;
    border: 0;
    background: transparent;
}

@media (min-width: 782px) {
    .tebuto-occurrence-settings-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1100px) {
    .tebuto-occurrence-settings-summary {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.tebuto-occurrence-summary-item {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tebuto-occurrence-summary-label {
    font-size: 12px;
    color: var(--tebuto-text-secondary, #6b7280);
    font-weight: 500;
}

.tebuto-occurrence-summary-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--tebuto-text, #111827);
    overflow-wrap: anywhere;
}

.tebuto-occurrence-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
    align-items: stretch;
}

@media (min-width: 1100px) {
    .tebuto-occurrence-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

.tebuto-occurrence-grid > .tebuto-card {
    min-width: 0;
}

.tebuto-definition-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.tebuto-definition-list > div {
    display: grid;
    gap: 2px;
}

.tebuto-definition-list dt {
    font-size: 12px;
    color: var(--tebuto-text-secondary, #6b7280);
    font-weight: 500;
}

.tebuto-definition-list dd {
    margin: 0;
    font-size: 14px;
    color: var(--tebuto-text, #111827);
}

.tebuto-sessions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tebuto-session-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--tebuto-border, #e5e7eb);
    border-radius: 8px;
    background: var(--tebuto-bg, #f9fafb);
}

.tebuto-sessions-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.wp-core-ui .tebuto-remove-session {
    width: 32px;
    height: 32px;
    padding: 0;
    flex-shrink: 0;
}

.wp-core-ui .tebuto-remove-session .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin: 0;
    line-height: 1;
}

@media (max-width: 782px) {
    .tebuto-accordion-header {
        flex-wrap: wrap;
    }

    .tebuto-accordion-body {
        padding-left: 16px;
    }

    .tebuto-session-row {
        grid-template-columns: 1fr;
    }
}
