/* CB GMB Plugin – Frontend Styles · v3.0 */
/* Override: add .cb-gmb-wrap { ... } in your theme */

/* ── CSS Custom Properties ─────────────────────────── */
:root {
    --gmb-open: #2d8659;
    --gmb-closed: #c0463f;
    --gmb-warn: #b8862d;
    --gmb-soon: var(--gmb-warn);
    --gmb-text: #202124;
    --gmb-text-secondary: #5f6368;
    --gmb-border: #e0e0e0;
    --gmb-bg: #ffffff;
    --gmb-star: #F9AB00;
    --gmb-primary: #1a73e8;
    --gmb-radius: 12px;
    --gmb-radius-sm: 8px;
    --gmb-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --gmb-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.12);
    --gmb-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Theming System ───────────────────────────────── */
/* Default: Avada theme variables with fallbacks */
[class*="cb-gmb-"] {
    --gmb-color-active: var(--awb-color4, var(--gmb-primary));
    --gmb-color-text: var(--awb-color3, var(--gmb-text));
    --gmb-color-light: var(--awb-color1, #ffffff);
}

/* Dark theme: white text for dark backgrounds */
.cb-gmb-theme-dark,
.cb-gmb-theme-dark .cb-gmb-day,
.cb-gmb-theme-dark .cb-gmb-time,
.cb-gmb-theme-dark .cb-gmb-closed-text,
.cb-gmb-theme-dark .cb-gmb-compact-today,
.cb-gmb-theme-dark .cb-gmb-compact-next,
.cb-gmb-theme-dark .cb-gmb-closed-item,
.cb-gmb-theme-dark .cb-gmb-ls-toggle {
    color: var(--gmb-color-light) !important;
}

/* Border variant */
.cb-gmb-border td {
    border: 1px solid var(--gmb-border) !important;
    padding: 6px 10px !important;
}
.cb-gmb-border .cb-gmb-closed-item {
    border: 1px solid var(--gmb-border);
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 4px;
}

/* ── Unstyled (CSS reset for theme conflicts) ─────── */
.cb-gmb-unstyled,
.cb-gmb-unstyled table,
.cb-gmb-unstyled tr,
.cb-gmb-unstyled td,
.cb-gmb-unstyled th {
    background: none !important;
    border: none !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    padding: 4px 12px 4px 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    outline: none !important;
}
.cb-gmb-unstyled tr:nth-child(even) td,
.cb-gmb-unstyled tr:nth-child(odd) td {
    background: none !important;
}

/* ── Striped (alternating background) ──────────────── */
.cb-gmb-striped tr:nth-child(even) td {
    background: var(--gmb-zebra, rgba(0, 0, 0, 0.03));
}
.cb-gmb-theme-dark.cb-gmb-striped tr:nth-child(even) td {
    background: var(--gmb-zebra, rgba(255, 255, 255, 0.06));
}

/* ── Opening Hours ─────────────────────────────────── */
.cb-gmb-hours {
    color: var(--gmb-color-text);
}

table.cb-gmb-hours,
.cb-gmb-hours table {
    border: 0 !important;
    border-collapse: collapse !important;
    width: max-content !important;
    table-layout: auto !important;
}

.cb-gmb-hours td {
    padding: 4px 12px 4px 0;
    vertical-align: top;
    white-space: nowrap;
}

.cb-gmb-hours tr.cb-gmb-today td {
    font-weight: 600;
    color: var(--gmb-color-active);
}

/* ── Closed text (no italic, no gray) ─────────────── */
.cb-gmb-closed-text {
    color: var(--gmb-closed);
}

.cb-gmb-fallback {
    color: #666;
    font-style: italic;
}

/* ── Summary (table format, grouped rows) ─────────── */
.cb-gmb-summary {
    color: var(--gmb-color-text);
}

/* ── Compact ───────────────────────────────────────── */
.cb-gmb-compact {
    color: var(--gmb-color-text);
}

.cb-gmb-compact-today {
    display: block;
}

.cb-gmb-compact-next {
    display: block;
    color: var(--gmb-text-secondary);
    margin-top: 2px;
}

/* ── Live Status ───────────────────────────────────── */
/* hide_empty="true": no text for the current case → nothing shown */
.cb-gmb-live-status.cb-gmb-ls-empty {
    display: none !important;
}

.cb-gmb-live-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--gmb-color-text);
}

/* Pill base (excludes dot format) */
.cb-gmb-status:not(.cb-gmb-dot) {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 25px;
    font-weight: 500;
    color: var(--gmb-pill-text, #fff);
    line-height: 1.4;
}

.cb-gmb-status.cb-gmb-open:not(.cb-gmb-dot) {
    background: var(--gmb-open);
}

.cb-gmb-status.cb-gmb-closed:not(.cb-gmb-dot) {
    background: var(--gmb-closed);
}

.cb-gmb-status.cb-gmb-warn:not(.cb-gmb-dot) {
    background: var(--gmb-warn);
}

.cb-gmb-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    animation: gmb-pulse 2s ease-in-out infinite;
}

/* Optional text beside the dot indicator (show_text="true") */
.cb-gmb-dot-text {
    margin-left: 4px;
    color: var(--gmb-color-text);
}

/* Colored text format (format="colortext"): like the pill, but no pill background.
   Each status rule resets the background too so it beats the pill background rules
   (.cb-gmb-status.cb-gmb-open:not(.cb-gmb-dot)) by equal specificity + later source order. */
.cb-gmb-ls-colortext .cb-gmb-status {
    padding: 0;
    border-radius: 0;
    font-weight: inherit;
    font-size: inherit;
    background: none;
    color: inherit;
}

.cb-gmb-ls-colortext .cb-gmb-status.cb-gmb-open:not(.cb-gmb-dot) {
    background: none;
    color: var(--gmb-open);
}

.cb-gmb-ls-colortext .cb-gmb-status.cb-gmb-closed:not(.cb-gmb-dot) {
    background: none;
    color: var(--gmb-closed);
}

.cb-gmb-ls-colortext .cb-gmb-status.cb-gmb-warn:not(.cb-gmb-dot) {
    background: none;
    color: var(--gmb-warn);
}

.cb-gmb-ls-colortext .cb-gmb-status.cb-gmb-soon:not(.cb-gmb-dot) {
    background: none;
    color: var(--gmb-soon);
}

.cb-gmb-open .cb-gmb-dot,
.cb-gmb-open.cb-gmb-dot {
    background: var(--gmb-open);
}

.cb-gmb-closed .cb-gmb-dot,
.cb-gmb-closed.cb-gmb-dot {
    background: var(--gmb-closed);
}

.cb-gmb-warn .cb-gmb-dot,
.cb-gmb-warn.cb-gmb-dot {
    background: var(--gmb-warn);
}

.cb-gmb-status.cb-gmb-soon:not(.cb-gmb-dot) {
    background: var(--gmb-soon);
}

.cb-gmb-soon .cb-gmb-dot,
.cb-gmb-soon.cb-gmb-dot {
    background: var(--gmb-soon);
}

@keyframes gmb-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.9); }
}

/* ── Live Status Accordion ─────────────────────────── */
.cb-gmb-ls-accordion {
    display: inline-block;
    position: relative;
}

.cb-gmb-ls-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px 0;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
}

.cb-gmb-ls-toggle:hover {
    opacity: 0.85;
}

.cb-gmb-ls-panel {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 999999;
    margin-top: 0;
    padding: 12px 16px;
    width: max-content;
    max-width: min(420px, 90vw);
    background: var(--gmb-color-light, #fff);
    border: 1px solid var(--gmb-border);
    border-radius: var(--gmb-radius-sm);
    box-shadow: var(--gmb-shadow-hover);
    overflow: hidden;
}

.cb-gmb-theme-dark .cb-gmb-ls-panel {
    background: #1e1e1e;
    border-color: #444;
}

.cb-gmb-ls-panel[hidden] {
    display: none;
}

/* Reset inner table spacing inside flyout */
.cb-gmb-ls-panel .cb-gmb-hours {
    margin: 0;
}

/* Optional heading inside the flyout (title of a Sprechzeiten table) */
.cb-gmb-ls-panel-title {
    margin: 0 0 8px;
    font-weight: 600;
    color: var(--gmb-color-text);
}

/* ── Rating ────────────────────────────────────────── */
.cb-gmb-rating {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cb-gmb-stars {
    display: inline-flex;
    gap: 2px;
}

.cb-gmb-star {
    vertical-align: middle;
}

.cb-gmb-rating-value {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--gmb-text);
}

.cb-gmb-rating-count {
    color: var(--gmb-text-secondary);
    font-size: 0.9em;
}

/* [gmb_rating_stars] – Font Awesome stars */
.cb-gmb-rating-stars {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    line-height: 1;
}

.cb-gmb-rating-stars-value {
    margin-left: 4px;
    font-weight: bold;
    color: var(--gmb-color-text);
}

/* Icons inside live-status texts */
.cb-gmb-status i,
.cb-gmb-dot-text i {
    margin: 0 0.15em;
}

/* ── Special Hours ─────────────────────────────────── */
.cb-gmb-special-hours {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cb-gmb-special-hours li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    transition: background var(--gmb-transition);
}

.cb-gmb-special-hours li:last-child {
    border-bottom: none;
}

.cb-gmb-special-hours li:hover {
    background: rgba(0, 0, 0, 0.02);
}

/* ── No data state ─────────────────────────────────── */
.cb-gmb-no-data {
    color: var(--gmb-text-secondary);
    font-style: italic;
    padding: 12px;
}

/* ── Closed days list ──────────────────────────────── */
.cb-gmb-closed-list {
    padding: 0;
    margin: 0;
    color: var(--gmb-color-text);
}

.cb-gmb-closed-list li {
    padding: 4px 0;
    list-style: none;
}

/* ── Hours Grid (multiple tables side by side) ─────── */
.cb-gmb-hours-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.cb-gmb-hours-grid .cb-gmb-hours {
    min-width: 0;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 600px) {
    .cb-gmb-hours td {
        padding: 3px 8px 3px 0;
    }

    /* Hours grid: 1 column on very small screens */
    .cb-gmb-hours-grid {
        grid-template-columns: 1fr;
    }
}

/* Medium screens: 2-3 tables side by side */
@media (min-width: 601px) and (max-width: 900px) {
    .cb-gmb-hours-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Accessibility ────────────────────────────────── */

/* Screen-reader-only caption (visible to assistive tech) */
.screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus styles for interactive elements */
.cb-gmb-ls-toggle:focus-visible {
    outline: 2px solid var(--gmb-primary, #1a73e8);
    outline-offset: 2px;
    border-radius: 4px;
}

.cb-gmb-anchor-pill:focus-visible {
    outline: 2px solid var(--gmb-primary, #1a73e8);
    outline-offset: 2px;
}

/* Reduced motion: disable animations for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .cb-gmb-dot {
        animation: none;
    }


    .cb-gmb-ls-panel {
        transition: none;
    }

    .cb-gmb-special-hours li {
        transition: none;
    }
}
