/* ── Booking by RP – Frontend styles ── */

/* All values driven by CSS custom properties set inline from PHP */
#brp-widget {
    --brp-primary:   #B32017;
    --brp-secondary: #ffffff;
    --brp-text:      #333333;
    --brp-bg:        #f9f9f9;
    --brp-border:    #dddddd;
    --brp-free:      #d4edda;
    --brp-partial:   #fff3cd;
    --brp-full:      #f8d7da;
    --brp-font:      inherit;
    --brp-fz:        16px;
    --brp-btn-r:     6px;
    --brp-widget-r:  8px;
    --brp-btn-fz:    16px;
}

/* ── Widget shell ── */
.brp-widget {
    position: relative;
    max-width: 700px;
    margin: 0 auto;
    background: var(--brp-bg);
    border: 1px solid var(--brp-border);
    border-radius: var(--brp-widget-r);
    padding: 28px 32px;
    font-family: var(--brp-font);
    font-size: var(--brp-fz);
    color: var(--brp-text);
    box-sizing: border-box;
}
@media (max-width: 600px) { .brp-widget { padding: 18px 16px; } }

/* ── Step header ── */
.brp-step-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
    font-weight: 700;
    margin: 0 0 20px;
    color: var(--brp-text);
}
.brp-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brp-primary);
    color: var(--brp-secondary);
    font-size: .85em;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Fields ── */
.brp-field { margin-bottom: 16px; }
.brp-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: .95em;
    color: var(--brp-text);
}
.brp-req { color: var(--brp-primary); margin-left: 2px; }

.brp-input,
.brp-select,
.brp-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--brp-border);
    border-radius: calc(var(--brp-btn-r) * 0.7);
    font-family: var(--brp-font);
    font-size: var(--brp-fz);
    color: var(--brp-text);
    background: #fff;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
    -webkit-appearance: none;
}
.brp-input:focus,
.brp-select:focus,
.brp-textarea:focus {
    outline: none;
    border-color: var(--brp-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brp-primary) 15%, transparent);
}
.brp-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}
.brp-textarea { min-height: 90px; resize: vertical; }
input[type="date"].brp-input,
input[type="time"].brp-input { cursor: pointer; }
input[type="date"].brp-input:read-only { background: #f5f5f5; cursor: default; }

/* ── Buttons ── */
.brp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 22px;
    border: 2px solid var(--brp-primary);
    border-radius: var(--brp-btn-r);
    background: var(--brp-primary);
    color: var(--brp-secondary);
    font-family: var(--brp-font);
    font-size: var(--brp-btn-fz);
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: opacity .15s, transform .1s;
    line-height: 1.2;
}
.brp-btn:hover   { opacity: .88; }
.brp-btn:active  { transform: scale(.97); }
.brp-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.brp-btn-ghost {
    background: transparent;
    color: var(--brp-primary);
}
.brp-btn-ghost:hover { background: color-mix(in srgb, var(--brp-primary) 8%, transparent); }

.brp-btn-icon {
    padding: 8px 14px;
    font-size: 1.3em;
    line-height: 1;
}

.brp-btn-submit { min-width: 180px; }

.brp-btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
    align-items: center;
}

/* ── Object cards ── */
.brp-object-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.brp-obj-card {
    border: 2px solid var(--brp-border);
    border-radius: calc(var(--brp-btn-r) * 0.8);
    padding: 14px 12px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .1s;
    background: #fff;
}
.brp-obj-card:hover  { border-color: var(--brp-primary); box-shadow: 0 2px 8px rgba(0,0,0,.1); transform: translateY(-1px); }
.brp-obj-card.active { border-color: var(--brp-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brp-primary) 20%, transparent); }

.brp-obj-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}
.brp-obj-name {
    font-weight: 700;
    font-size: .95em;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}
.brp-obj-desc {
    font-size: .82em;
    color: #666;
    margin-top: 6px;
    line-height: 1.4;
}

/* ── Calendar ── */
.brp-cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.brp-cal-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: .82em;
    flex-wrap: wrap;
    color: #666;
}
.brp-legend-chip {
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,.1);
    vertical-align: middle;
    margin-right: 4px;
}

.brp-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    user-select: none;
}
.brp-cal-header {
    text-align: center;
    font-size: .8em;
    font-weight: 700;
    color: #888;
    padding: 4px 0;
}
.brp-cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: .9em;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color .12s, opacity .12s;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}
.brp-cal-day.empty   { pointer-events: none; cursor: default; }
.brp-cal-day.past    { opacity: .35; pointer-events: none; cursor: default; }
.brp-cal-day.free    { background: var(--brp-free); }
.brp-cal-day.partial { background: var(--brp-partial); }
.brp-cal-day.full    { background: var(--brp-full); opacity: .6; pointer-events: none; cursor: default; }
.brp-cal-day.today   { font-weight: 700; }
.brp-cal-day:hover:not(.empty):not(.past):not(.full) { border-color: var(--brp-primary); }

.brp-cal-day.start,
.brp-cal-day.end {
    background: var(--brp-primary) !important;
    color: var(--brp-secondary) !important;
    border-color: var(--brp-primary) !important;
    font-weight: 700;
}
.brp-cal-day.in-range {
    background: color-mix(in srgb, var(--brp-primary) 18%, white) !important;
    border-radius: 0;
}

/* ── Date/time grid ── */
.brp-datetime-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}
@media (max-width: 480px) { .brp-datetime-grid { grid-template-columns: 1fr; } }

/* ── Divider ── */
.brp-divider { border: none; border-top: 1px solid var(--brp-border); margin: 20px 0; }

/* ── Hint ── */
.brp-hint { font-size: .85em; color: #888; margin: 8px 0 0; font-style: italic; }

/* ── Summary box ── */
.brp-summary {
    background: #fff;
    border: 1px solid var(--brp-border);
    border-left: 4px solid var(--brp-primary);
    border-radius: 4px;
    padding: 14px 16px;
    margin-bottom: 20px;
    font-size: .92em;
    line-height: 1.6;
}
.brp-summary strong { color: var(--brp-text); }

/* ── Alerts ── */
.brp-alert {
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: .92em;
    line-height: 1.5;
}
.brp-alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.brp-alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.brp-alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Success screen ── */
.brp-success { text-align: center; padding: 32px 16px; }
.brp-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--brp-primary);
    color: var(--brp-secondary);
    font-size: 28px;
    margin-bottom: 16px;
}
.brp-success-title { font-size: 1.3em; font-weight: 700; margin: 0 0 10px; }
.brp-success-msg   { color: #555; margin: 0 0 24px; line-height: 1.6; }

/* ── Loading overlay ── */
.brp-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.75);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--brp-widget-r);
    z-index: 10;
}
.brp-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--brp-border);
    border-top-color: var(--brp-primary);
    border-radius: 50%;
    animation: brp-spin .7s linear infinite;
}
@keyframes brp-spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════
   Calendar View  [booking_rp_calendar]
═══════════════════════════════════════════════════════ */

.brp-calview { position: relative; }

.brp-calview-title {
    font-size: 1.1em;
    font-weight: 700;
    margin: 0 0 16px;
    color: var(--brp-primary);
}

/* Clickable days get a pointer + subtle ring on hover */
.brp-cview-has-detail { cursor: pointer; }
.brp-cview-has-detail:hover { box-shadow: 0 0 0 2px var(--brp-primary); }
.brp-cview-has-detail:focus { outline: 2px solid var(--brp-primary); outline-offset: 1px; }

/* Full days in the calendar VIEW are still clickable – override the booking widget rule */
.brp-calview .brp-cal-day.full {
    pointer-events: auto;
    opacity: 1;
    cursor: pointer;
}

/* Color dots inside day cell */
.brp-cview-dots {
    display: flex;
    gap: 3px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 3px;
}
.brp-cview-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,.15);
}

/* Detail panel */
.brp-cview-detail {
    margin-top: 16px;
    border: 1px solid var(--brp-border);
    border-radius: calc(var(--brp-widget-r) * 0.7);
    overflow: hidden;
    background: #fff;
}
.brp-cview-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--brp-primary);
    color: var(--brp-secondary);
    font-size: .95em;
}
.brp-cview-detail-close {
    background: none;
    border: none;
    color: var(--brp-secondary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: .8;
}
.brp-cview-detail-close:hover { opacity: 1; }

.brp-cview-detail-body { padding: 10px 14px; }
.brp-cview-detail-body:empty::after {
    content: 'Inga bokningar denna dag.';
    color: #888;
    font-size: .9em;
    font-style: italic;
}

/* Booking item row */
.brp-cview-booking-item {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 10px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px solid var(--brp-border);
    font-size: .9em;
}
.brp-cview-booking-item:last-child { border-bottom: none; }
.brp-cview-booking-item .brp-obj-dot {
    grid-row: 1 / 3;
    align-self: center;
    width: 12px; height: 12px;
}
.brp-cview-type-label {
    display: block;
    font-size: .8em;
    color: #888;
    font-weight: normal;
}
.brp-cview-times {
    grid-column: 2;
    font-size: .82em;
    color: #666;
    margin-top: 2px;
}
.brp-cview-status {
    grid-row: 1;
    grid-column: 3;
    font-size: .78em;
    white-space: nowrap;
    align-self: center;
}

/* ── Calendar view: booking button ── */
.brp-cview-book-btn {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
}

.brp-cview-no-bookings {
    color: #888;
    font-size: .9em;
    font-style: italic;
    margin: 4px 0 0;
}

/* Small "+" indicator on free days with booking URL */
.brp-cview-book-indicator {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: .65em;
    color: var(--brp-primary);
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}
