/**
 * Nakhon Sawan City Municipality - Cookie Consent & Privacy Manager
 * Phase 1: Core Design System & Styling
 */

:root {
    --nsm-cookie-bg: rgba(15, 23, 42, 0.95);
    --nsm-cookie-border: rgba(245, 158, 11, 0.35);
    --nsm-cookie-gold: #f59e0b;
    --nsm-cookie-purple: #9333ea;
    --nsm-cookie-purple-dark: #7e22ce;
    --nsm-cookie-text: #f8fafc;
    --nsm-cookie-muted: #94a3b8;
}

/* ===== Floating Banner ===== */
.nsm-cookie-banner {
    position: fixed;
    bottom: 24px;
    left: 20px;
    right: 20px;
    max-width: 1180px;
    margin: 0 auto;
    background: var(--nsm-cookie-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--nsm-cookie-border);
    border-top: 3px solid var(--nsm-cookie-gold);
    border-radius: 16px;
    padding: 22px 26px;
    color: var(--nsm-cookie-text);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08);
    z-index: 99990;
    font-family: 'Kanit', sans-serif;
    opacity: 0;
    visibility: hidden;
    transform: translateY(30px);
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), 
                transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), 
                visibility 0.35s;
    pointer-events: none;
}

.nsm-cookie-banner.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.nsm-cookie-banner-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.nsm-cookie-content {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    flex: 1;
}

.nsm-cookie-icon-wrap {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(147, 51, 234, 0.25) 100%);
    border: 1px solid rgba(245, 158, 11, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

.nsm-cookie-text-block {
    flex: 1;
}

.nsm-cookie-title {
    margin: 0 0 6px 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nsm-cookie-title-badge {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.nsm-cookie-desc {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: #cbd5e1;
}

.nsm-cookie-links {
    display: inline-flex;
    gap: 12px;
    margin-top: 4px;
}

.nsm-cookie-link {
    color: #fcd34d;
    text-decoration: underline;
    text-underline-offset: 3px;
    font-size: 0.84rem;
    transition: color 0.2s ease;
}

.nsm-cookie-link:hover {
    color: #ffffff;
}

/* Actions in Banner */
.nsm-cookie-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.nsm-cookie-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 10px;
    font-family: 'Kanit', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: none;
    outline: none;
}

.nsm-cookie-btn-primary {
    background: linear-gradient(135deg, #a855f7 0%, #7e22ce 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(126, 34, 206, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.nsm-cookie-btn-primary:hover {
    background: linear-gradient(135deg, #b969fb 0%, #9333ea 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(126, 34, 206, 0.45);
}

.nsm-cookie-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.nsm-cookie-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

.nsm-cookie-btn-ghost {
    background: transparent;
    color: #94a3b8;
    padding: 10px 14px;
}

.nsm-cookie-btn-ghost:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

/* ===== Preferences Modal ===== */
.nsm-cookie-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99995;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: 'Kanit', sans-serif;
}

.nsm-cookie-modal-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.nsm-cookie-modal {
    background: #ffffff;
    width: 100%;
    max-width: 680px;
    max-height: 88vh;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid #e2e8f0;
}

.nsm-cookie-modal-backdrop.is-open .nsm-cookie-modal {
    transform: scale(1);
}

/* Modal Header */
.nsm-cookie-modal-header {
    background: linear-gradient(135deg, #1e1b4b 0%, #4c1d95 60%, #7e22ce 100%);
    padding: 20px 24px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid var(--nsm-cookie-gold);
}

.nsm-cookie-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nsm-cookie-modal-close {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

.nsm-cookie-modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* Modal Body */
.nsm-cookie-modal-body {
    padding: 24px;
    overflow-y: auto;
    color: #334155;
    font-size: 0.9rem;
    line-height: 1.6;
}

.nsm-cookie-modal-intro {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--nsm-cookie-purple);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    color: #475569;
    font-size: 0.86rem;
}

/* Category Cards */
.nsm-cookie-category-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.nsm-cookie-cat-item {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    background: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nsm-cookie-cat-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.nsm-cookie-cat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 6px;
}

.nsm-cookie-cat-title {
    font-size: 0.98rem;
    font-weight: 600;
    color: #1e1b4b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nsm-cookie-cat-desc {
    margin: 0;
    font-size: 0.84rem;
    color: #64748b;
    line-height: 1.5;
}

/* Custom Switch Toggle */
.nsm-cookie-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.nsm-cookie-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.nsm-cookie-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #cbd5e1;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 34px;
}

.nsm-cookie-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.nsm-cookie-toggle input:checked + .nsm-cookie-slider {
    background-color: var(--nsm-cookie-purple);
}

.nsm-cookie-toggle input:checked + .nsm-cookie-slider:before {
    transform: translateX(22px);
}

.nsm-cookie-toggle.is-locked .nsm-cookie-slider {
    background-color: #64748b;
    cursor: not-allowed;
    opacity: 0.75;
}

.nsm-cookie-badge-locked {
    font-size: 0.74rem;
    font-weight: 600;
    color: #059669;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Modal Footer */
.nsm-cookie-modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.nsm-cookie-btn-modal-save {
    background: #1e1b4b;
    color: #ffffff;
}

.nsm-cookie-btn-modal-save:hover {
    background: #312e81;
}

/* ===== Floating Re-open Badge (Revoke / Reopen Settings) ===== */
.nsm-cookie-revoke-btn {
    position: fixed;
    bottom: 24px;
    left: 20px;
    background: rgba(30, 27, 75, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #ffffff;
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 999px;
    padding: 8px 14px;
    font-family: 'Kanit', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    z-index: 9990;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s ease;
    opacity: 0.85;
}

.nsm-cookie-revoke-btn:hover {
    opacity: 1;
    transform: translateY(-2px);
    background: #1e1b4b;
    box-shadow: 0 6px 18px rgba(126, 34, 206, 0.35);
    border-color: var(--nsm-cookie-gold);
}

/* ===== Responsive Breakpoints ===== */
@media (max-width: 900px) {
    .nsm-cookie-banner-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 18px;
    }
    
    .nsm-cookie-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .nsm-cookie-banner {
        bottom: 12px;
        left: 12px;
        right: 12px;
        padding: 16px 18px;
        border-radius: 14px;
    }

    .nsm-cookie-content {
        gap: 12px;
    }

    .nsm-cookie-icon-wrap {
        width: 38px;
        height: 38px;
        font-size: 1.25rem;
    }

    .nsm-cookie-title {
        font-size: 1rem;
    }

    .nsm-cookie-desc {
        font-size: 0.82rem;
    }

    .nsm-cookie-actions {
        flex-direction: column;
        gap: 8px;
    }

    .nsm-cookie-btn {
        width: 100%;
        padding: 9px 16px;
        font-size: 0.88rem;
    }

    .nsm-cookie-modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .nsm-cookie-btn-modal-save,
    .nsm-cookie-modal-footer .nsm-cookie-btn {
        width: 100%;
    }

    .nsm-cookie-revoke-btn {
        bottom: 16px;
        left: 12px;
        padding: 6px 12px;
        font-size: 0.74rem;
    }
}
