/* =============================================
   Cookie Consent — PDPA Thailand
   โรงพยาบาลกรุงเทพจันทบุรี v1.0
   ============================================= */

/* =============================================
   Overlay
   ============================================= */
#cookie-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    display: none;
}
#cookie-overlay.show {
    display: block;
}

/* =============================================
   Banner
   ============================================= */
#cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 3px solid #1a73e8;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    padding: 20px 48px 20px 24px; /* padding-right เผื่อปุ่ม X */
    display: none;
    animation: cookieSlideUp 0.4s ease;
}
#cookie-banner.show {
    display: block;
}

@keyframes cookieSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.cookie-banner-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.cookie-banner-icon {
    font-size: 2rem;
    flex-shrink: 0;
    line-height: 1.2;
}

.cookie-banner-content {
    flex: 1;
    min-width: 260px;
}
.cookie-banner-content h5 {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
}
.cookie-banner-content p {
    margin: 0;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.6;
}
.cookie-banner-content a {
    color: #1a73e8;
    text-decoration: underline;
}
.cookie-banner-content a:hover {
    color: #1558b0;
}

.cookie-banner-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

/* =============================================
   ปุ่ม X — Dismiss Banner / Modal
   ============================================= */
.cookie-banner-dismiss {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: 1px solid #dadce0;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
    line-height: 1;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}
.cookie-banner-dismiss:hover {
    background: #f5f5f5;
    color: #333;
    border-color: #aaa;
}

/* Tooltip สำหรับปุ่ม X */
.cookie-banner-dismiss::after,
.cookie-modal-close::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #333;
    color: #fff;
    font-size: 0.72rem;
    padding: 5px 9px;
    border-radius: 5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1;
    max-width: 200px;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
    width: max-content;
}
.cookie-banner-dismiss:hover::after,
.cookie-modal-close:hover::after {
    opacity: 1;
}

/* =============================================
   Buttons
   ============================================= */
.btn-cookie-accept-all {
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 22px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
.btn-cookie-accept-all:hover {
    background: #1558b0;
}

.btn-cookie-reject-all {
    background: #f1f3f4;
    color: #333;
    border: 1px solid #dadce0;
    border-radius: 6px;
    padding: 10px 22px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
.btn-cookie-reject-all:hover {
    background: #e2e4e6;
}

.btn-cookie-settings {
    background: transparent;
    color: #1a73e8;
    border: 1px solid #1a73e8;
    border-radius: 6px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-cookie-settings:hover {
    background: #e8f0fe;
}

/* =============================================
   Modal
   ============================================= */
#cookie-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.24);
    z-index: 100000;
    width: 560px;
    max-width: 95vw;
    max-height: 85vh;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s, opacity 0.3s;
    opacity: 0;
}
#cookie-modal.show {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.cookie-modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.cookie-modal-header h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
}

.cookie-modal-close {
    position: relative;
    background: none;
    border: 1px solid #dadce0;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1rem;
    cursor: pointer;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
.cookie-modal-close:hover {
    background: #f5f5f5;
    color: #333;
    border-color: #aaa;
}

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

/* =============================================
   Cookie Type Cards
   ============================================= */
.cookie-type-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}
.cookie-type-card:last-of-type {
    margin-bottom: 0;
}
.cookie-type-card:hover {
    border-color: #c5cae9;
}

.cookie-type-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 12px;
}

.cookie-type-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1a1a1a;
}

.cookie-type-desc {
    font-size: 0.82rem;
    color: #666;
    line-height: 1.6;
    margin: 0;
}

/* =============================================
   Toggle Switch
   ============================================= */
.cookie-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.cookie-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}
.cookie-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.cookie-toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.3s;
}
.cookie-toggle-slider:before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    left: 3px;
    bottom: 3px;
    transition: transform 0.3s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.cookie-toggle input:checked + .cookie-toggle-slider {
    background: #1a73e8;
}
.cookie-toggle input:checked + .cookie-toggle-slider:before {
    transform: translateX(20px);
}
.cookie-toggle input:disabled + .cookie-toggle-slider {
    background: #a8d5a2;
    cursor: not-allowed;
}
.cookie-toggle input:disabled ~ .cookie-toggle-slider {
    cursor: not-allowed;
}

/* =============================================
   Modal Footer
   ============================================= */
.cookie-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.cookie-modal-footer button {
    flex: 1;
    min-width: 120px;
}

/* =============================================
   Notice Box (หมายเหตุการปิด)
   ============================================= */
.cookie-dismiss-notice {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 16px;
}
.cookie-dismiss-notice p {
    font-size: 0.8rem;
    color: #795548;
    margin: 0;
    line-height: 1.6;
}

/* =============================================
   Floating Trigger Button
   ============================================= */
#cookie-trigger {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 10px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 9999;
    display: none;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}
#cookie-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(26, 115, 232, 0.5);
}
#cookie-trigger.show {
    display: flex;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 640px) {
    #cookie-banner {
        padding: 16px 44px 16px 16px;
    }
    .cookie-banner-inner {
        flex-direction: column;
        gap: 14px;
    }
    .cookie-banner-actions {
        width: 100%;
    }
    .cookie-banner-actions button {
        flex: 1;
        min-width: 0;
    }
    #cookie-modal {
        max-height: 92vh;
        border-radius: 12px 12px 0 0;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
    }
    #cookie-modal.show {
        transform: none;
    }
    .cookie-modal-footer {
        flex-direction: column;
    }
    .cookie-modal-footer button {
        width: 100%;
    }
    #cookie-trigger {
        bottom: 80px; /* เผื่อ nav bar ด้านล่างบน mobile */
    }

    /* ซ่อน tooltip บน mobile (ใช้ title แทน) */
    .cookie-banner-dismiss::after,
    .cookie-modal-close::after {
        display: none;
    }
}

@media (max-width: 380px) {
    .cookie-banner-actions {
        flex-direction: column;
    }
}
