/* ============================================
   Big C Cookie Consent — PDPA compliant
   Brand colors: Green #93d600 / Red #d81b26
   ============================================ */

:root {
    --bcc-green: #93d600;
    --bcc-green-dark: #7eb800;
    --bcc-red: #d81b26;
    --bcc-red-dark: #b3171f;
    --bcc-text: #1f2937;
    --bcc-text-light: #4b5563;
    --bcc-border: #e5e7eb;
    --bcc-bg: #f3f4f6;
}

/* Overlay — frosted glass blur effect */
.bcc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: 999998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, backdrop-filter 0.25s ease;
}

.bcc-overlay.bcc-visible {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================
   Banner (first-time consent)
   ============================================ */
.bcc-banner {
    position: fixed;
    z-index: 999997;
    bottom: 24px;
    left: 24px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
    width: calc(100% - 48px);
    max-width: 460px;
    padding: 24px 24px 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Sukhumvit Set",
        "Sarabun", "Prompt", Helvetica, Arial, sans-serif;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-top: 4px solid var(--bcc-green);
}

.bcc-banner.bcc-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.bcc-banner-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.bcc-banner-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
}

.bcc-banner-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--bcc-text);
    margin: 0;
    line-height: 1.2;
}

.bcc-banner-body {
    color: var(--bcc-text-light);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 18px;
}

.bcc-banner-body a {
    color: var(--bcc-red);
    text-decoration: underline;
}

.bcc-banner-divider {
    height: 1px;
    background: var(--bcc-border);
    margin: 0 -24px 16px;
}

.bcc-banner-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ============================================
   Buttons
   ============================================ */
.bcc-btn {
    display: block;
    width: 100%;
    padding: 12px 18px;
    border: 2px solid transparent;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    transition: background-color 0.15s ease, transform 0.05s ease, border-color 0.15s ease;
    box-sizing: border-box;
}

.bcc-btn:active {
    transform: scale(0.98);
}

/* Big C Green — Accept all / Reject all (same level for PDPA) */
.bcc-btn-primary {
    background: var(--bcc-green);
    color: #ffffff;
    border-color: var(--bcc-green);
}

.bcc-btn-primary:hover {
    background: var(--bcc-green-dark);
    border-color: var(--bcc-green-dark);
}

/* Big C Red — Save preferences / Manage */
.bcc-btn-secondary {
    background: var(--bcc-red);
    color: #ffffff;
    border-color: var(--bcc-red);
}

.bcc-btn-secondary:hover {
    background: var(--bcc-red-dark);
    border-color: var(--bcc-red-dark);
}

/* Outline green — Reject (alternative style if wanted) */
.bcc-btn-outline {
    background: #ffffff;
    color: var(--bcc-green);
    border-color: var(--bcc-green);
}

.bcc-btn-outline:hover {
    background: var(--bcc-green);
    color: #ffffff;
}

/* ============================================
   Modal (preferences setting)
   ============================================ */
.bcc-modal {
    position: fixed;
    z-index: 999999;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    width: calc(100% - 32px);
    max-width: 800px;
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Sukhumvit Set",
        "Sarabun", "Prompt", Helvetica, Arial, sans-serif;
}

.bcc-modal.bcc-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%);
}

.bcc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px 20px;
    border-bottom: 1px solid var(--bcc-border);
}

.bcc-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--bcc-text);
    margin: 0;
}

.bcc-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--bcc-red);
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bcc-modal-close:hover {
    background: var(--bcc-red-dark);
}

.bcc-modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
}

.bcc-modal-intro h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--bcc-text);
    margin: 0 0 8px;
}

.bcc-modal-intro p {
    color: var(--bcc-text-light);
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 24px;
}

/* Category card */
.bcc-cat {
    background: var(--bcc-bg);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.bcc-cat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    cursor: pointer;
    user-select: none;
}

.bcc-cat-arrow {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #d1d5db;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.bcc-cat.bcc-open .bcc-cat-arrow {
    transform: rotate(180deg);
}

.bcc-cat-name {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
    color: var(--bcc-text);
}

.bcc-cat-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 18px;
    color: var(--bcc-text-light);
    font-size: 13px;
    line-height: 1.55;
}

.bcc-cat.bcc-open .bcc-cat-detail {
    max-height: 800px;
    padding: 0 18px 18px;
}

.bcc-cat-desc {
    margin-bottom: 12px;
}

.bcc-empty-note {
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
    margin: 0;
}

/* Cookie table */
.bcc-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
}

.bcc-table th,
.bcc-table td {
    text-align: left;
    padding: 9px 11px;
    font-size: 12px;
    border-bottom: 1px solid var(--bcc-border);
    vertical-align: top;
    color: var(--bcc-text-light);
}

.bcc-table th {
    background: #fafafa;
    font-weight: 700;
    color: var(--bcc-text);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bcc-table tbody tr:last-child td {
    border-bottom: none;
}

.bcc-table .bcc-cookie-name {
    font-family: Menlo, Monaco, "Courier New", monospace;
    font-size: 12px;
    color: var(--bcc-red);
    word-break: break-all;
}

.bcc-table .bcc-cookie-domain {
    color: var(--bcc-green-dark);
    font-size: 12px;
}

/* Mobile table → card layout */
@media (max-width: 600px) {
    .bcc-table {
        background: transparent;
        border-radius: 0;
    }
    .bcc-table thead {
        display: none;
    }
    .bcc-table tbody tr {
        display: block;
        background: #ffffff;
        border-radius: 8px;
        padding: 10px 12px;
        margin-bottom: 8px;
        border: 1px solid var(--bcc-border);
    }
    .bcc-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 6px 0;
        border-bottom: 1px dashed #eee;
        font-size: 12px;
    }
    .bcc-table td:last-child {
        border-bottom: none;
    }
    .bcc-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--bcc-text);
        text-transform: uppercase;
        font-size: 10px;
        letter-spacing: 0.5px;
        flex-shrink: 0;
        min-width: 70px;
        padding-top: 1px;
    }
    .bcc-table td.bcc-cookie-name,
    .bcc-table td.bcc-cookie-domain {
        font-size: 12px;
        text-align: right;
    }
}

/* Toggle switch */
.bcc-switch {
    position: relative;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.bcc-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.bcc-switch-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.bcc-switch-slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    top: 3px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.bcc-switch input:checked + .bcc-switch-slider {
    background: var(--bcc-green);
}

.bcc-switch input:checked + .bcc-switch-slider::before {
    transform: translateX(22px);
}

.bcc-switch.bcc-locked .bcc-switch-slider,
.bcc-switch.bcc-locked input:checked + .bcc-switch-slider {
    background: #9ca3af;
    cursor: not-allowed;
}

.bcc-modal-footer {
    padding: 18px 24px;
    border-top: 1px solid var(--bcc-border);
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: nowrap;
}

.bcc-modal-footer .bcc-btn {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    padding: 11px 12px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bcc-modal-footer-group {
    display: flex;
    gap: 10px;
    flex: 2 1 0;
    flex-wrap: nowrap;
}

.bcc-modal-footer-group .bcc-btn {
    flex: 1 1 0;
}

/* ============================================
   Floating Cookie Button (after consent)
   ============================================ */
.bcc-fab {
    position: fixed;
    z-index: 999997;
    bottom: 24px;
    left: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid var(--bcc-green);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    padding: 0;
    line-height: 1;
}

.bcc-fab.bcc-visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.bcc-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    background: var(--bcc-green);
}

.bcc-fab:hover .bcc-fab-tooltip {
    opacity: 1;
    transform: translate(0, -50%);
}

.bcc-fab-tooltip {
    position: absolute;
    left: calc(100% + 12px);
    right: auto;
    top: 50%;
    transform: translate(-10px, -50%);
    background: #1f2937;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.bcc-fab-tooltip::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: #1f2937;
}

/* Settings link in footer */
.bcc-settings-link {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    text-decoration: underline;
    font: inherit;
    padding: 0;
}

.bcc-settings-link:hover {
    color: var(--bcc-green);
}

/* ============================================
   Responsive
   ============================================ */
/* ============================================
   Mobile responsive
   ============================================ */
@media (max-width: 600px) {
    /* Banner — fit within viewport */
    .bcc-banner {
        bottom: 12px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        padding: 16px 14px 14px;
        border-top-width: 3px;
    }

    .bcc-banner-header {
        gap: 8px;
        margin-bottom: 10px;
    }

    .bcc-banner-icon {
        width: 28px;
        height: 28px;
        font-size: 22px;
    }

    .bcc-banner-title {
        font-size: 16px;
    }

    .bcc-banner-body {
        font-size: 12px;
        line-height: 1.5;
        margin-bottom: 12px;
    }

    .bcc-banner-divider {
        margin: 0 -14px 12px;
    }

    .bcc-banner-actions {
        gap: 8px;
    }

    .bcc-banner-actions .bcc-btn {
        padding: 10px 14px;
        font-size: 14px;
    }

    /* Modal */
    .bcc-modal {
        width: calc(100% - 16px);
        max-height: calc(100vh - 32px);
    }

    .bcc-modal-header {
        padding: 16px 16px 14px;
    }

    .bcc-modal-body {
        padding: 16px 16px;
    }

    .bcc-modal-title {
        font-size: 17px;
    }

    .bcc-modal-close {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .bcc-modal-intro h3 {
        font-size: 14px;
    }

    .bcc-modal-intro p {
        font-size: 12px;
        margin-bottom: 18px;
    }

    /* Category card on mobile */
    .bcc-cat-head {
        padding: 12px 14px;
        gap: 10px;
    }

    .bcc-cat-arrow {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }

    .bcc-cat-name {
        font-size: 13px;
        line-height: 1.3;
    }

    .bcc-cat.bcc-open .bcc-cat-detail {
        padding: 0 14px 14px;
        font-size: 12px;
    }

    .bcc-switch {
        width: 42px;
        height: 24px;
    }

    .bcc-switch-slider::before {
        height: 18px;
        width: 18px;
        top: 3px;
    }

    .bcc-switch input:checked + .bcc-switch-slider::before {
        transform: translateX(18px);
    }

    /* Modal footer — stack vertically full width, NO ellipsis */
    .bcc-modal-footer {
        padding: 14px 16px;
        flex-direction: column-reverse;
        gap: 8px;
        align-items: stretch;
    }

    .bcc-modal-footer .bcc-btn {
        width: 100%;
        flex: 0 0 auto;
        min-width: 0;
        padding: 11px 14px;
        font-size: 14px;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }

    .bcc-modal-footer-group {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        flex: 0 0 auto;
    }

    .bcc-modal-footer-group .bcc-btn {
        width: 100%;
    }

    /* Floating button */
    .bcc-fab {
        bottom: 14px;
        left: 14px;
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    .bcc-fab-tooltip {
        display: none;
    }
}

@media (max-width: 380px) {
    .bcc-banner-title {
        font-size: 15px;
    }
    .bcc-banner-body {
        font-size: 11.5px;
    }
    .bcc-banner-actions .bcc-btn,
    .bcc-modal-footer .bcc-btn {
        font-size: 13px;
        padding: 10px 12px;
    }
}
