/**
 * SkyGrammar Cookie Consent — banner & modal styles.
 */
.sgcc,
.sgcc * { box-sizing: border-box; }

/* Ensure the HTML [hidden] attribute always wins over display rules below.
   Without this, display:flex on .sgcc-modal / #sgcc-root would override
   [hidden] and show the element (causing a phantom second popup). */
#sgcc-root[hidden],
.sgcc-modal[hidden],
.sgcc-reopen[hidden] { display: none !important; }

.sgcc {
    --sgcc-accent: #4F46E5;
    --sgcc-bg: #ffffff;
    --sgcc-text: #33333b;
    --sgcc-heading: #1b1b1f;
    --sgcc-border: rgba(20, 20, 30, 0.12);
    --sgcc-muted: #6b6b76;
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

/* Positions */
.sgcc--bottom-left { left: 20px; bottom: 20px; }
.sgcc--bottom-right { right: 20px; bottom: 20px; }
.sgcc--bottom-center { left: 50%; bottom: 20px; transform: translateX(-50%); }

/* ---- Banner ---- */
.sgcc-banner {
    background: var(--sgcc-bg);
    color: var(--sgcc-text);
    border: 1px solid var(--sgcc-border);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(10, 10, 30, 0.18);
    padding: 20px 22px;
    max-width: 420px;
}
.sgcc--bar .sgcc-banner {
    max-width: none;
    width: calc(100vw - 40px);
    display: flex;
    align-items: center;
    gap: 20px;
}
.sgcc--bar.sgcc--bottom-left,
.sgcc--bar.sgcc--bottom-right { left: 20px; right: 20px; }

.sgcc-title {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--sgcc-heading);
}
.sgcc-message { margin: 0; color: var(--sgcc-text); }
.sgcc-privacy-link { color: var(--sgcc-accent); text-decoration: underline; }

.sgcc-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.sgcc--bar .sgcc-banner-actions { margin-top: 0; flex-shrink: 0; }

/* ---- Buttons ---- */
.sgcc-btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
    transition: filter 0.15s ease, background 0.15s ease;
    min-height: 42px;
}
.sgcc-btn-primary {
    background: var(--sgcc-accent);
    color: #fff;
}
.sgcc-btn-primary:hover { filter: brightness(1.08); }
.sgcc-btn-ghost {
    background: transparent;
    color: var(--sgcc-heading);
    border-color: var(--sgcc-border);
}
.sgcc-btn-ghost:hover { background: rgba(20, 20, 30, 0.04); }

/* ---- Modal ---- */
.sgcc-modal {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.sgcc-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 20, 0.5);
}
.sgcc-modal-card {
    position: relative;
    background: var(--sgcc-bg);
    border-radius: 18px;
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(10, 10, 30, 0.3);
    z-index: 1;
}
.sgcc-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px;
    border-bottom: 1px solid var(--sgcc-border);
    position: sticky;
    top: 0;
    background: var(--sgcc-bg);
}
.sgcc-modal-head h2 { margin: 0; font-size: 1.15rem; color: var(--sgcc-heading); }
.sgcc-modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: var(--sgcc-muted);
    padding: 0 4px;
}
.sgcc-modal-body { padding: 8px 22px 4px; }
.sgcc-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 22px 22px;
    flex-wrap: wrap;
}

/* ---- Categories ---- */
.sgcc-cat {
    padding: 16px 0;
    border-bottom: 1px solid var(--sgcc-border);
}
.sgcc-cat:last-child { border-bottom: none; }
.sgcc-cat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.sgcc-cat-desc { margin: 6px 0 0; color: var(--sgcc-muted); font-size: 0.88rem; }
.sgcc-cat-always { font-size: 0.75rem; font-weight: 700; color: var(--sgcc-accent); text-transform: uppercase; letter-spacing: 0.03em; }

/* Toggle switch */
.sgcc-switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.sgcc-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.sgcc-slider {
    position: relative;
    width: 44px;
    height: 26px;
    background: #c9cdd6;
    border-radius: 999px;
    transition: background 0.2s ease;
    flex: 0 0 auto;
}
.sgcc-slider::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.sgcc-switch input:checked + .sgcc-slider { background: var(--sgcc-accent); }
.sgcc-switch input:checked + .sgcc-slider::before { transform: translateX(18px); }
.sgcc-switch input:disabled + .sgcc-slider { opacity: 0.7; }
.sgcc-cat-label { font-weight: 600; color: var(--sgcc-heading); }

/* ---- Reopen button ---- */
.sgcc-reopen {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 999998;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid var(--sgcc-border, rgba(20,20,30,.12));
    background: #fff;
    box-shadow: 0 6px 20px rgba(10, 10, 30, 0.18);
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
}
.sgcc-reopen:hover { filter: brightness(1.05); }

/* ---- Dark mode support (matches sites using a dark theme) ---- */
@media (prefers-color-scheme: dark) {
    .sgcc {
        --sgcc-bg: #1b1e26;
        --sgcc-text: #c7cad1;
        --sgcc-heading: #f4f5f7;
        --sgcc-border: rgba(255, 255, 255, 0.14);
        --sgcc-muted: #8b8f9a;
    }
    .sgcc-reopen { background: #1b1e26; color: #f4f5f7; }
}

/* ---- Mobile ---- */
@media (max-width: 600px) {
    .sgcc--bottom-left,
    .sgcc--bottom-right,
    .sgcc--bottom-center {
        left: 10px;
        right: 10px;
        bottom: 10px;
        transform: none;
    }
    .sgcc-banner { max-width: none; width: auto; }
    .sgcc--bar .sgcc-banner { flex-direction: column; align-items: stretch; }
    .sgcc-banner-actions .sgcc-btn { flex: 1; }
}
