/*
 * Styles for the Thai PDPA Compliance Suite Public Pop-up
 * Updated with Modal Layout Support
 */

/* --- Pop-up Container (Base Styles) --- */
.tpcs-cookie-popup-container {
    position: fixed;
    z-index: 9999;
    font-family: 'Inter', Arial, sans-serif;
    color: var(--tpcs-text-color, #333);
    transition: all 0.3s ease;
    backdrop-filter: blur(var(--tpcs-blur-radius));
    -webkit-backdrop-filter: blur(var(--tpcs-blur-radius));
    background-color: var(--tpcs-bg-color);
    border: 1px solid var(--tpcs-border-color, #ccc);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.tpcs-cookie-content {
    display: flex;
    /* This will be overridden by specific layouts below for column flow */
    align-items: center; /* Default, will be overridden for column layouts */
    width: 100%;
    max-width: 1200px; /* Base max-width, individual layouts will set their own */
    margin: auto;
}

.tpcs-cookie-content p {
    margin: 0;
    flex-grow: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal; /* Ensure text wraps */
    font-size: 14px;
    width: 100%; /* Ensure text takes full available width */
    max-width: 100%; /* Ensure text takes full available width */
    /* margin-bottom will be handled by layout overrides */
    margin-right: 0 !important; /* Remove any lingering right margin from previous attempts */
}

.tpcs-cookie-content a {
    color: var(--tpcs-button-color, #0073aa);
    text-decoration: none;
}

.tpcs-cookie-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0; /* Prevent buttons from shrinking too much */
    flex-wrap: wrap; /* Allow buttons to wrap if they exceed container width, though they should fit now */
}

.tpcs-button {
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s;
    white-space: nowrap; /* Ensure button text doesn't wrap inside the button itself */
}

.tpcs-button-accept {
    background-color: var(--tpcs-button-color, #0073aa);
    color: var(--tpcs-button-text-color, #fff);
}

.tpcs-button-accept:hover {
    background-color: var(--tpcs-button-color-hover, #005177);
}

.tpcs-button-settings {
    background-color: #e5e5e5;
    color: #333;
}

.tpcs-button-settings:hover {
    background-color: #d4d4d4;
}

/* --- Modal Container (for the settings window) --- */
.tpcs-modal-container {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.tpcs-modal-container.is-open {
    display: flex;
}

/* Modal Layout Styles */

/* 1. Modal Center (Default) */
.tpcs-modal-center {
    justify-content: center;
    align-items: center;
}

.tpcs-modal-center .tpcs-modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    font-family: 'Inter', Arial, sans-serif;
    color: var(--tpcs-text-color, #333);
    animation: modalFadeIn 0.3s ease-out;
}

/* 2. Modal Bottom Right */
.tpcs-modal-bottom-right {
    justify-content: flex-end;
    align-items: flex-end;
    padding: 32px; /* more breathing room on desktop */
    padding-right: calc(32px + env(safe-area-inset-right));
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

.tpcs-modal-bottom-right .tpcs-modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    width: 90%;
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.2);
    font-family: 'Inter', Arial, sans-serif;
    color: var(--tpcs-text-color, #333);
    animation: slideInUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    margin-right: 0;
    margin-left: auto;
}

/* 3. Modal Bottom Left */
.tpcs-modal-bottom-left {
    justify-content: flex-start;
    align-items: flex-end;
    padding: 32px; /* more breathing room on desktop */
    padding-left: calc(32px + env(safe-area-inset-left));
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

.tpcs-modal-bottom-left .tpcs-modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    width: 90%;
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.2);
    font-family: 'Inter', Arial, sans-serif;
    color: var(--tpcs-text-color, #333);
    animation: slideInUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    margin-left: 0;
    margin-right: auto;
}

/* Desktop-only spacing for bottom-left / bottom-right modals */
@media (min-width: 1024px) {
  .tpcs-modal-bottom-right,
  .tpcs-modal-bottom-left {
    padding: 40px; /* more room on desktop */
  }
  .tpcs-modal-bottom-right { 
    padding-right: calc(40px + env(safe-area-inset-right));
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }
  .tpcs-modal-bottom-left  { 
    padding-left: calc(40px + env(safe-area-inset-left));
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 1440px) {
  .tpcs-modal-bottom-right,
  .tpcs-modal-bottom-left {
    padding: 48px; /* extra breathing room on very large screens */
  }
}

/* Lift bottom-left/right modals above the edge on desktop and round all corners */
@media (min-width: 1024px) {
  .tpcs-modal-bottom-right .tpcs-modal-content,
  .tpcs-modal-bottom-left  .tpcs-modal-content {
    border-radius: 12px;        /* all corners rounded so it doesn't look attached */
    margin-bottom: 35px;        /* lift higher: +15px from previous */
  }
  /* add side gaps */
  .tpcs-modal-bottom-right .tpcs-modal-content { margin-right: 55px; }
  .tpcs-modal-bottom-left  .tpcs-modal-content { margin-left: 55px; }
}

@media (min-width: 1440px) {
  .tpcs-modal-bottom-right .tpcs-modal-content,
  .tpcs-modal-bottom-left  .tpcs-modal-content {
    margin-bottom: 55px;        /* +15px from previous */
  }
}

/* 4. Modal Sidebar Right */
.tpcs-modal-sidebar-right {
    justify-content: flex-end;
    align-items: stretch;
    padding: 0;
}

.tpcs-modal-sidebar-right .tpcs-modal-content {
    background-color: #fff;
    padding: 0;
    border-radius: 0;
    width: 100%;
    max-width: 450px;
    height: 100vh;
    overflow-y: auto;
    position: relative;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.2);
    font-family: 'Inter', Arial, sans-serif;
    color: var(--tpcs-text-color, #333);
    animation: slideInRight 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
}

.tpcs-modal-sidebar-right .tpcs-modal-header {
    padding: 20px 20px 15px 20px;
    border-bottom: 1px solid var(--tpcs-border-color, #eee);
    flex-shrink: 0;
}

.tpcs-modal-sidebar-right .tpcs-modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.tpcs-modal-sidebar-right .tpcs-modal-footer {
    padding: 15px 20px 20px 20px;
    border-top: 1px solid var(--tpcs-border-color, #eee);
    flex-shrink: 0;
}

/* 5. Modal Sidebar Left */
.tpcs-modal-sidebar-left {
    justify-content: flex-start;
    align-items: stretch;
    padding: 0;
}

.tpcs-modal-sidebar-left .tpcs-modal-content {
    background-color: #fff;
    padding: 0;
    border-radius: 0;
    width: 100%;
    max-width: 450px;
    height: 100vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
    font-family: 'Inter', Arial, sans-serif;
    color: var(--tpcs-text-color, #333);
    animation: slideInLeft 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
}

.tpcs-modal-sidebar-left .tpcs-modal-header {
    padding: 20px 20px 15px 20px;
    border-bottom: 1px solid var(--tpcs-border-color, #eee);
    flex-shrink: 0;
}

.tpcs-modal-sidebar-left .tpcs-modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.tpcs-modal-sidebar-left .tpcs-modal-footer {
    padding: 15px 20px 20px 20px;
    border-top: 1px solid var(--tpcs-border-color, #eee);
    flex-shrink: 0;
}

/* Modal Header Styles (Default) */
.tpcs-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--tpcs-border-color, #eee);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.tpcs-modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.tpcs-modal-close-button {
    font-size: 24px;
    cursor: pointer;
    border: none;
    background: none;
    line-height: 1;
    color: var(--tpcs-text-color, #333);
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tpcs-modal-close-button:hover {
    opacity: 1;
}

/* Modal Body Styles */
.tpcs-modal-body {
    padding-bottom: 20px;
}

/* ส่วนของ Modal Body ที่มี Scrollbar จะถูกจัดการโดย JavaScript */
.tpcs-modal-body.scrollable-body {
    /* JavaScript จะเพิ่ม max-height และ overflow-y ให้ */
    padding-right: 15px; /* เพิ่ม padding ด้านขวาเพื่อไม่ให้เนื้อหาชน scrollbar */
    padding-bottom: 5px; /* ลด padding ด้านล่างเล็กน้อยเมื่อมี scrollbar */
}

/* สไตล์ Scrollbar สำหรับ WebKit browsers (Chrome, Safari, Edge) */
.tpcs-modal-body.scrollable-body::-webkit-scrollbar {
    width: 8px;
}

.tpcs-modal-body.scrollable-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.tpcs-modal-body.scrollable-body::-webkit-scrollbar-thumb {
    background: var(--tpcs-button-color, #0073aa);
    border-radius: 4px;
}

.tpcs-modal-body.scrollable-body::-webkit-scrollbar-thumb:hover {
    background: var(--tpcs-button-color-hover, #005177);
}

.tpcs-modal-body .tpcs-cookie-modal-intro {
    margin-bottom: 20px;
    font-size: 15px;
}

.tpcs-cookie-category {
    border-bottom: 1px solid var(--tpcs-border-color, #eee);
    padding: 15px 0;
}

.tpcs-cookie-category:last-child {
    border-bottom: none;
}

.tpcs-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.tpcs-category-header h4 {
    margin: 0;
    font-size: 17px;
    font-weight: normal;
}

/* คุณอาจจะต้องปรับขนาด font ของ h3 ใน header ของ modal ด้วย ถ้ายังไม่ได้ตั้งค่า */
/* เพื่อให้ h4 ของ sidebar ดูเล็กกว่า h3 ของ header อย่างชัดเจน */
#tpcs-cookie-modal .tpcs-modal-header h4 {
    font-size: 22px; /* ทำให้ใหญ่และโดดเด่น */
    font-weight: bold;
}

/* ปรับขนาดตัวอักษรสำหรับหัวข้อ Sidebar ใน Modal */
/* โดยใช้ ID หรือ class ที่เฉพาะเจาะจงมากขึ้น */
#tpcs-cookie-modal #tpcs-modal-sidebar-text h5 {
    font-size: 14px; /* ปรับขนาดให้เล็กกว่าหัวข้อหลักของ Modal (h3) */
    font-weight: 100; /* อาจจะลดความหนาลงเล็กน้อย */
    margin-top: 15px; 
    margin-bottom: 5px; 
}

.tpcs-category-description {
    margin-top: 5px;
    font-size: 13px;
    color: #777;
    line-height: 1.4;
}

.tpcs-required-label {
    background-color: #f0f0f0;
    color: #555;
    font-size: 10px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Switch Toggle */
.tpcs-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.tpcs-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tpcs-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.tpcs-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .tpcs-slider {
    background-color: var(--tpcs-button-color, #0073aa);
}

input:checked + .tpcs-slider:before {
    transform: translateX(20px);
}

.tpcs-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--tpcs-border-color, #eee);
}

/* Responsive adjustments for modal buttons */
.tpcs-modal-footer .tpcs-button {
    flex: 1;
    min-width: auto;
}

.tpcs-modal-footer .tpcs-button-settings {
    font-size: 13px;
    border: 1px solid var(--tpcs-border-color, #ccc);
}

.tpcs-modal-footer .tpcs-button-accept {
     font-size: 13px;
}

@media (min-width: 500px) {
    .tpcs-modal-footer .tpcs-button {
        flex: 1;
        min-width: 120px;
    }
    .tpcs-modal-footer .tpcs-button-settings {
        font-size: 13px;
        border: 1px solid var(--tpcs-border-color, #ccc);
    }
    .tpcs-modal-footer .tpcs-button-accept {
        font-size: 13px;
    }
}

/* Modal Animation Keyframes */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* --- Layout (Positioning) Styles for Cookie Popup --- */

/* Full Bottom */
.tpcs-layout-full-bottom {
    bottom: 0;
    left: 0;
    width: 100%;
    border-top: 1px solid var(--tpcs-border-color, #ccc);
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}

.tpcs-layout-full-bottom .tpcs-cookie-content {
    flex-wrap: wrap; /* Allow content to wrap */
    flex-direction: column; /* Ensure column stacking for text and buttons */
    align-items: flex-start; /* Align content to the left */
    text-align: left; /* Align text to the left */
    padding: 20px 30px;
}
.tpcs-layout-full-bottom .tpcs-cookie-content p {
    margin-bottom: 15px; /* Add space below text before buttons */
    margin-right: 0; /* Remove right margin */
    width: 100%; /* Ensure text takes full width */
}
.tpcs-layout-full-bottom .tpcs-cookie-buttons {
    width: auto; /* Allow buttons to take their natural width */
    flex-direction: row; /* Keep buttons side by side */
    justify-content: flex-start; /* Align buttons to the left */
    flex-wrap: wrap; /* Allow buttons to wrap if needed */
}

/* Center Bottom */
.tpcs-layout-center-bottom {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    border: 1px solid var(--tpcs-border-color, #ccc);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}
.tpcs-layout-center-bottom .tpcs-cookie-content {
    flex-direction: column; /* Ensure column stacking for text and buttons */
    align-items: flex-start; /* Align content to the left */
    text-align: left; /* Align text to the left */
    padding: 24px;
    gap: 14px; /* consistent vertical spacing between text and buttons */
    width: 100%;
    max-width: 100%;
    margin: 0;              /* override global margin:auto */
    box-sizing: border-box; /* include padding in width to prevent overflow */
}
.tpcs-layout-center-bottom .tpcs-cookie-content p {
    margin-bottom: 0; /* spacing handled by .tpcs-cookie-content gap */
    margin-right: 0; /* Remove right margin */
    width: 100%; /* Ensure text takes full width */
}
.tpcs-layout-center-bottom .tpcs-cookie-buttons {
    width: auto; /* Allow buttons to take their natural width */
    flex-direction: row; /* Keep buttons side by side */
    justify-content: flex-start; /* Align buttons to the left */
    flex-wrap: wrap; /* Allow buttons to wrap if needed */
    margin: 0;
}

/* Box Bottom Right */
.tpcs-layout-box-bottom-right {
    bottom: 20px;
    right: 20px;
    width: auto;
    max-width: 600px;
    border: 1px solid var(--tpcs-border-color, #ccc);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box; /* ensure borders/padding don't push content outside */
}
.tpcs-layout-box-bottom-right .tpcs-cookie-content {
    flex-direction: column; /* Ensure column stacking for text and buttons */
    align-items: flex-start; /* Align content to the left */
    text-align: left; /* Align text to the left */
    padding: 24px;
    gap: 14px; /* consistent vertical spacing between text and buttons */
    width: 100%;
    max-width: 100%;
    margin: 0;              /* override global margin:auto */
    box-sizing: border-box; /* include padding in width to prevent overflow */
}
.tpcs-layout-box-bottom-right .tpcs-cookie-content p {
    margin-bottom: 0; /* spacing handled by .tpcs-cookie-content gap */
    margin-right: 0; /* Remove right margin */
    width: 100%; /* Ensure text takes full width */
}
.tpcs-layout-box-bottom-right .tpcs-cookie-buttons {
    width: auto; /* Allow buttons to take their natural width */
    flex-direction: row; /* Keep buttons side by side */
    justify-content: flex-start; /* Align buttons to the left */
    flex-wrap: wrap; /* Allow buttons to wrap if needed */
    margin: 0;
}

/* Sidebar Left */
.tpcs-layout-sidebar-left {
    top: 0;
    bottom: 0;
    left: 0;
    width: 380px;
    border-right: 1px solid var(--tpcs-border-color, #ccc);
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    display: flex; /* Ensure flexbox for vertical alignment */
    flex-direction: column; /* Stack content vertically */
    justify-content: flex-start;
    align-items: flex-start;
    /* Reverted padding to ensure content is not cut off */
    padding: 0; /* Important: remove any direct padding on the container itself */
}
.tpcs-layout-sidebar-left .tpcs-cookie-content {
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1; /* Allow content to grow and take available space */
    padding: 30px 30px 20px 30px; /* Reverted to original padding for sidebar content */
    overflow-y: auto; /* เพิ่ม scrollbar ถ้าเนื้อหายาวเกินไป */
    box-sizing: border-box; /* Ensure padding is included in the element's total width and height */
}
.tpcs-layout-sidebar-left .tpcs-cookie-content p {
    margin: 0 0 15px 0; /* Space below text */
    max-width: 100%;
    text-align: left; /* Ensure text alignment */
    /* No margin-right here */
}
.tpcs-layout-sidebar-left .tpcs-cookie-buttons {
    flex-direction: column; /* Keep buttons stacked in sidebar */
    width: 100%; /* Make buttons take full width */
    margin-top: auto; /* Push buttons to the bottom */
    padding: 0 30px 20px 30px; /* Reverted to original padding for sidebar buttons */
    align-items: flex-start; /* Align buttons to the left in sidebar */
    flex-wrap: wrap; /* Allow buttons to wrap if needed */
    box-sizing: border-box; /* Ensure padding is included in the element's total width and height */
}
.tpcs-layout-sidebar-left .tpcs-button {
    width: 100%; /* Ensure buttons take full width of their container */
}

/* Sidebar Right */
.tpcs-layout-sidebar-right {
    top: 0;
    bottom: 0;
    right: 0;
    width: 380px;
    border-left: 1px solid var(--tpcs-border-color, #ccc);
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    display: flex; /* Ensure flexbox for vertical alignment */
    flex-direction: column; /* Stack content vertically */
    justify-content: flex-start;
    align-items: flex-start;
    /* Reverted padding to ensure content is not cut off */
    padding: 0; /* Important: remove any direct padding on the container itself */
}
.tpcs-layout-sidebar-right .tpcs-cookie-content {
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1; /* Allow content to grow and take available space */
    padding: 30px 30px 20px 30px; /* Reverted to original padding for sidebar content */
    overflow-y: auto; /* เพิ่ม scrollbar ถ้าเนื้อหายาวเกินไป */
    box-sizing: border-box; /* Ensure padding is included in the element's total width and height */
}
.tpcs-layout-sidebar-right .tpcs-cookie-content p {
    margin: 0 0 15px 0; /* Space below text */
    max-width: 100%;
    text-align: left; /* Ensure text alignment */
    /* No margin-right here */
}
.tpcs-layout-sidebar-right .tpcs-cookie-buttons {
    flex-direction: column; /* Keep buttons stacked in sidebar */
    width: 100%; /* Make buttons take full width */
    margin-top: auto; /* Push buttons to the bottom */
    padding: 0 30px 20px 30px; /* Reverted to original padding for sidebar buttons */
    align-items: flex-start; /* Align buttons to the left in sidebar */
    flex-wrap: wrap; /* Allow buttons to wrap if needed */
    box-sizing: border-box; /* Ensure padding is included in the element's total width and height */
}
.tpcs-layout-sidebar-right .tpcs-button {
    width: 100%; /* Ensure buttons take full width of their container */
}

/* New Layouts */
.tpcs-layout-box-bottom-left {
    bottom: 20px;
    left: 20px;
    width: auto;
    max-width: 600px;
    border: 1px solid var(--tpcs-border-color, #ccc);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box; /* ensure borders/padding don't push content outside */
}
.tpcs-layout-box-bottom-left .tpcs-cookie-content {
    flex-direction: column; /* Ensure column stacking for text and buttons */
    align-items: flex-start; /* Align content to the left */
    text-align: left; /* Align text to the left */
    padding: 24px;
    gap: 14px; /* consistent vertical spacing between text and buttons */
    width: 100%;
    max-width: 100%;
    margin: 0;              /* override global margin:auto */
    box-sizing: border-box; /* include padding in width to prevent overflow */
}
.tpcs-layout-box-bottom-left .tpcs-cookie-content p {
    margin-bottom: 0; /* spacing handled by .tpcs-cookie-content gap */
    margin-right: 0; /* Remove right margin */
    width: 100%; /* Ensure text takes full width */
}
.tpcs-layout-box-bottom-left .tpcs-cookie-buttons {
    width: auto; /* Allow buttons to take their natural width */
    flex-direction: row; /* Keep buttons side by side */
    justify-content: flex-start; /* Align buttons to the left */
    flex-wrap: wrap; /* Allow buttons to wrap if needed */
    margin: 0;
}

.tpcs-layout-center-top {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    border: 1px solid var(--tpcs-border-color, #ccc);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}
.tpcs-layout-center-top .tpcs-cookie-content {
    flex-direction: column; /* Ensure column stacking for text and buttons */
    align-items: flex-start; /* Align content to the left */
    text-align: left; /* Align text to the left */
    padding: 24px;
    gap: 14px; /* consistent vertical spacing between text and buttons */
    width: 100%;
    max-width: 100%;
    margin: 0;              /* override global margin:auto */
    box-sizing: border-box; /* include padding in width to prevent overflow */
}
.tpcs-layout-center-top .tpcs-cookie-content p {
    margin-bottom: 0; /* spacing handled by .tpcs-cookie-content gap */
    margin-right: 0; /* Remove right margin */
    width: 100%; /* Ensure text takes full width */
}
.tpcs-layout-center-top .tpcs-cookie-buttons {
    width: auto; /* Allow buttons to take their natural width */
    flex-direction: row; /* Keep buttons side by side */
    justify-content: flex-start; /* Align buttons to the left */
    flex-wrap: wrap; /* Allow buttons to wrap if needed */
    margin: 0;
}

.tpcs-layout-box-top-left {
    top: 20px;
    left: 20px;
    width: auto;
    max-width: 600px;
    border: 1px solid var(--tpcs-border-color, #ccc);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box; /* ensure borders/padding don't push content outside */
}
.tpcs-layout-box-top-left .tpcs-cookie-content {
    flex-direction: column; /* Ensure column stacking for text and buttons */
    align-items: flex-start; /* Align content to the left */
    text-align: left; /* Align text to the left */
    padding: 24px;
    gap: 14px; /* consistent vertical spacing between text and buttons */
    width: 100%;
    max-width: 100%;
    margin: 0;              /* override global margin:auto */
    box-sizing: border-box; /* include padding in width to prevent overflow */
}
.tpcs-layout-box-top-left .tpcs-cookie-content p {
    margin-bottom: 0; /* spacing handled by .tpcs-cookie-content gap */
    margin-right: 0; /* Remove right margin */
    width: 100%; /* Ensure text takes full width */
}
.tpcs-layout-box-top-left .tpcs-cookie-buttons {
    width: auto; /* Allow buttons to take their natural width */
    flex-direction: row; /* Keep buttons side by side */
    justify-content: flex-start; /* Align buttons to the left */
    flex-wrap: wrap; /* Allow buttons to wrap if needed */
    margin: 0;
}

.tpcs-layout-box-top-right {
    top: 20px;
    right: 20px;
    width: auto;
    max-width: 600px;
    border: 1px solid var(--tpcs-border-color, #ccc);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box; /* ensure borders/padding don't push content outside */
}
.tpcs-layout-box-top-right .tpcs-cookie-content {
    flex-direction: column; /* Ensure column stacking for text and buttons */
    align-items: flex-start; /* Align content to the left */
    text-align: left; /* Align text to the left */
    padding: 24px;
    gap: 14px; /* consistent vertical spacing between text and buttons */
    width: 100%;
    max-width: 100%;
    margin: 0;              /* override global margin:auto */
    box-sizing: border-box; /* include padding in width to prevent overflow */
}
.tpcs-layout-box-top-right .tpcs-cookie-content p {
    margin-bottom: 0; /* spacing handled by .tpcs-cookie-content gap */
    margin-right: 0; /* Remove right margin */
    width: 100%; /* Ensure text takes full width */
}
.tpcs-layout-box-top-right .tpcs-cookie-buttons {
    width: auto; /* Allow buttons to take their natural width */
    flex-direction: row; /* Keep buttons side by side */
    justify-content: flex-start; /* Align buttons to the left */
    flex-wrap: wrap; /* Allow buttons to wrap if needed */
    margin: 0;
}

/* --- Size & Style Classes --- */

/* Small Size */
.tpcs-style-small {
    /* No direct padding override here, let layout specific padding apply */
}
.tpcs-style-small .tpcs-cookie-content p {
    font-size: 13px;
    margin-bottom: 10px; /* Small space below text */
}
.tpcs-style-small .tpcs-button {
    padding: 8px 16px;
    font-size: 12px;
}
.tpcs-style-small.tpcs-layout-full-bottom .tpcs-cookie-content {
    padding-top: 15px; /* Keep original padding-top for full-bottom small */
    padding-left: 15px; /* Adjusted padding-left for consistency */
    padding-right: 20px; /* Adjusted padding-right for consistency */
}

/* Medium Size (Default) */
.tpcs-style-default {
    /* No direct padding override here, let layout specific padding apply */
}
.tpcs-style-default .tpcs-cookie-content p {
    font-size: 14px;
    margin-bottom: 15px; /* Medium space below text */
}
.tpcs-style-default .tpcs-button {
    padding: 10px 20px;
    font-size: 14px;
}

/* Large Size */
.tpcs-style-large {
    /* No direct padding override here, let layout specific padding apply */
}
.tpcs-style-large .tpcs-cookie-content p {
    font-size: 16px;
    margin-bottom: 20px; /* Large space below text */
}
.tpcs-style-large .tpcs-button {
    padding: 12px 24px;
    font-size: 16px;
}

/* Rounded Style */
.tpcs-style-rounded {
    border-radius: 25px;
}
.tpcs-style-rounded .tpcs-button {
    border-radius: 20px;
}
.tpcs-style-rounded.tpcs-layout-full-bottom {
    border-radius: 25px 25px 0 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 750px;
    width: 90%;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.2);
    border-top: 1px solid var(--tpcs-border-color, #ccc);
    border-left: 1px solid var(--tpcs-border-color, #ccc);
    border-right: 1px solid var(--tpcs-border-color, #ccc);
    border-bottom: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tpcs-cookie-popup-container {
        bottom: 0 !important;
        left: 0 !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        border: none !important;
        border-top: 1px solid var(--tpcs-border-color, #ccc) !important;
        box-shadow: 0 -2px 5px rgba(0,0,0,0.1) !important;
        padding: 15px !important; /* Ensure consistent padding on mobile */
    }
    
    .tpcs-cookie-content {
        flex-direction: column; /* Always column on mobile */
        align-items: center; /* Center on mobile by default */
        text-align: center; /* Center text on mobile by default */
        padding-top: 15px !important;
        padding-bottom: 0 !important; 
        padding-left: 15px !important; /* Ensure padding on mobile */
        padding-right: 15px !important; /* Ensure padding on mobile */
        flex-wrap: wrap !important; /* Ensure content wraps on mobile */
    }
    .tpcs-cookie-content p {
        margin: 0 0 15px 0;
        margin-right: 0 !important; /* Reset margin-right on mobile */
        width: 100%; /* Ensure text takes full width */
    }
    .tpcs-cookie-buttons {
        width: 100%;
        flex-direction: column; /* Buttons stacked on mobile */
        margin-top: 15px !important;
        padding-bottom: 0 !important;
        justify-content: center; /* Center buttons horizontally on mobile */
        align-items: center; /* Center buttons horizontally on mobile */
    }
    .tpcs-button {
        width: 100%; /* Buttons take full width of their container on mobile */
        white-space: normal !important; /* Allow button text to wrap on mobile if needed */
    }

    /* Modal specific responsive */
    .tpcs-modal-container.tpcs-modal-sidebar-left,
    .tpcs-modal-container.tpcs-modal-sidebar-right {
        padding: 0;
    }
    
    .tpcs-modal-container.tpcs-modal-sidebar-left .tpcs-modal-content,
    .tpcs-modal-container.tpcs-modal-sidebar-right .tpcs-modal-content {
        max-width: 100%;
        width: 100%;
        border-radius: 0;
    }
    
    .tpcs-modal-container.tpcs-modal-bottom-right,
    .tpcs-modal-container.tpcs-modal-bottom-left {
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        padding-left: calc(12px + env(safe-area-inset-left));
        padding-right: calc(12px + env(safe-area-inset-right));
    }
    
    .tpcs-modal-container.tpcs-modal-bottom-right .tpcs-modal-content,
    .tpcs-modal-container.tpcs-modal-bottom-left .tpcs-modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 12px 12px 0 0; /* keep a gap from edges and rounded top */
        margin: 0;
    }
    
    .tpcs-modal-container.tpcs-modal-center .tpcs-modal-content {
        width: 95%;
        margin: 20px;
    }
}

/*------- Cookie Details Modal Theme --------*/
/* Category Actions */
.tpcs-category-actions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.tpcs-cookie-details-btn {
    background: none;
    border: none;
    color: var(--tpcs-button-color, #0073aa);
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    margin: 0;
    transition: color 0.2s ease;
}

.tpcs-cookie-details-btn:hover {
    color: var(--tpcs-button-color-hover, #005177);
}

/* Details Modal Specific Styles */
.tpcs-details-modal .tpcs-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.tpcs-modal-back-button {
    font-size: 20px;
    cursor: pointer;
    border: none;
    background: none;
    color: var(--tpcs-text-color, #333);
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 5px;
    margin-right: 10px;
    border-radius: 4px;
}

.tpcs-modal-back-button:hover {
    opacity: 1;
    background: rgba(0,0,0,0.1);
}

.tpcs-details-modal .tpcs-modal-header h3 {
    flex: 1;
    text-align: center;
    margin: 0 40px; /* Space for back and close buttons */
}

/* Cookie Details Content */
.tpcs-cookie-details-content {
    padding: 16px;
}

/* Cookie Details Table (DB-aware rendering) */
.tpcs-cookie-table { 
    width: 100%;
    overflow-x: auto; /* allow horizontal scroll on small screens */
}
.tpcs-cookie-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px; /* prevents columns from squashing on small screens */
}
.tpcs-cookie-table thead th {
    background: #f9fafb;
    color: #4a5568;
    font-weight: 600;
    text-align: left;
    font-size: 14px;
    border-bottom: 2px solid #e5e7eb;
    padding: 10px 12px;
    position: sticky;
    top: 0; /* keep header visible when scrolling */
    z-index: 1;
}
.tpcs-cookie-table tbody td {
    padding: 10px 12px;
    font-size: 14px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}
.tpcs-cookie-table tbody tr:hover { 
    background: #f9fafb; 
}
.tpcs-cookie-table code {
    background: #e2e8f0;
    color: #1f2937;
    padding: 2px 6px;
    border-radius: 4px;
}

@media (max-width: 768px) {
    .tpcs-cookie-table table {
        min-width: 540px; /* slightly smaller on mobile */
    }
    .tpcs-cookie-table thead th,
    .tpcs-cookie-table tbody td {
        font-size: 13px;
        padding: 8px 10px;
    }
}

.tpcs-cookie-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    background: #fafbfc;
    transition: all 0.2s ease;
}

.tpcs-cookie-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e0;
}

.tpcs-cookie-item:last-child {
    margin-bottom: 0;
}

.tpcs-cookie-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.tpcs-cookie-name {
    font-family: 'Courier New', Consolas, monospace;
    font-size: 16px;
    font-weight: bold;
    color: var(--tpcs-text-color, #333);
    background: #e2e8f0;
    padding: 4px 8px;
    border-radius: 4px;
    margin: 0;
}

.tpcs-cookie-provider {
    font-size: 12px;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 10px;
}

.tpcs-cookie-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 10px 0;
}

.tpcs-info-item {
    display: flex;
    flex-direction: column;
}

.tpcs-info-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tpcs-info-value {
    font-size: 14px;
    color: var(--tpcs-text-color, #333);
    font-weight: 500;
}

.tpcs-cookie-purpose {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e5e7eb;
}

.tpcs-purpose-title {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tpcs-purpose-text {
    font-size: 14px;
    color: var(--tpcs-text-color, #333);
    line-height: 1.5;
}

/* Loading Spinner */
.tpcs-loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #64748b;
}

.tpcs-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f1f5f9;
    border-top: 4px solid var(--tpcs-button-color, #0073aa);
    border-radius: 50%;
    animation: tpcs-spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes tpcs-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.tpcs-empty-cookies {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
}

.tpcs-empty-cookies .tpcs-empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.tpcs-empty-cookies p {
    margin: 5px 0;
    font-size: 16px;
}

.tpcs-empty-cookies small {
    font-size: 14px;
    color: #6b7280;
}

/* Responsive Design for Details Modal */
@media (max-width: 768px) {
    .tpcs-details-modal .tpcs-modal-content {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        margin: 0;
    }
    
    .tpcs-cookie-info {
        grid-template-columns: 1fr;
    }
    
    .tpcs-cookie-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tpcs-cookie-provider {
        margin-left: 0;
        margin-top: 5px;
    }
    
    .tpcs-details-modal .tpcs-modal-header h3 {
        margin: 0 30px;
        font-size: 18px;
    }
}

/* Cookie Details – Card Layout (mobile-first) */
.tpcs-cookie-cards { 
    display: grid; 
    gap: 16px; 
}
.tpcs-cookie-card { 
    background: #fff; 
    border: 1px solid #d1d5db; /* gray-300 */
    border-radius: 10px; 
    padding: 16px; 
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.tpcs-cookie-card .tpcs-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 6px 0;
}
.tpcs-cookie-card .tpcs-label {
    color: #374151; /* gray-700 */
    font-weight: 600;
    white-space: nowrap;
    flex: 0 0 120px;
    max-width: 40%;
}
.tpcs-cookie-card .tpcs-value {
    color: #111827; /* gray-900 */
    line-height: 1.6;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    flex: 1 1 auto;
    min-width: 0; /* allow the value column to grow/shrink correctly */
}
.tpcs-cookie-card code { 
    background: #f3f4f6; 
    color: #1f2937; 
    padding: 2px 6px; 
    border-radius: 4px; 
}
@media (min-width: 992px) {
    .tpcs-cookie-cards { grid-template-columns: 1fr 1fr; }
}

/* Center layout – show cookie cards full width (single column) on desktop */
@media (min-width: 992px) {
  .tpcs-details-modal.tpcs-modal-center .tpcs-cookie-cards { grid-template-columns: 1fr !important; }
}

/* Optional: match label width to other layouts on desktop */
@media (min-width: 1024px) {
  .tpcs-details-modal.tpcs-modal-center .tpcs-cookie-card .tpcs-label { flex-basis: 150px; }
}

/* Animation for modal transitions */
.tpcs-details-modal {
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.tpcs-details-modal.is-open {
    opacity: 1;
    visibility: visible;
}

/* Expiry warning colors */
.tpcs-info-value.expiry-session {
    color: #f59e0b;
    font-weight: 600;
}

.tpcs-info-value.expiry-persistent {
    color: #10b981;
}

.tpcs-info-value.expiry-long {
    color: #ef4444;
}

/* Highlight effect */
.tpcs-cookie-item.highlight-temp {
    background: #e0f2fe;
    border-color: #0891b2;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.2);
}
/* Center layout: keep responsive but cap to a comfortable width */
.tpcs-details-modal.tpcs-modal-center .tpcs-modal-content {
    /* min 320px, scale with viewport (72vw), cap at 960px */
    width: clamp(320px, 72vw, 600px);
    max-width: none; /* clamp already limits size */
}
@media (min-width: 1440px) {
    .tpcs-details-modal.tpcs-modal-center .tpcs-modal-content {
        width: 600px; /* fixed ceiling on ultra‑wide screens */
    }
}

/* Fine-tune label column on very small screens */
@media (max-width: 480px) {
    .tpcs-cookie-card .tpcs-label { flex-basis: 150px; }
}
@media (max-width: 360px) {
    .tpcs-cookie-card .tpcs-label { flex-basis: 150px; }
}


/* ===== Cookie Details – Desktop tweaks for sidebar + bottom layouts (desktop) ===== */
@media (min-width: 1024px) {
  /* Widen the details panel on desktop */
  .tpcs-details-modal.tpcs-modal-bottom-right .tpcs-modal-content,
  .tpcs-details-modal.tpcs-modal-bottom-left  .tpcs-modal-content,
  .tpcs-details-modal.tpcs-modal-sidebar-right .tpcs-modal-content,
  .tpcs-details-modal.tpcs-modal-sidebar-left  .tpcs-modal-content {
    width: 96%;
    max-width: 500px; /* wider than default */
  }

  /* Keep cookie cards as a single column so each card is full width */
  .tpcs-details-modal.tpcs-modal-bottom-right .tpcs-cookie-cards,
  .tpcs-details-modal.tpcs-modal-bottom-left  .tpcs-cookie-cards,
  .tpcs-details-modal.tpcs-modal-sidebar-right .tpcs-cookie-cards,
  .tpcs-details-modal.tpcs-modal-sidebar-left  .tpcs-cookie-cards {
    grid-template-columns: 1fr !important;
  }

  /* Give labels a bit more room on desktop */
  .tpcs-details-modal.tpcs-modal-bottom-right .tpcs-cookie-card .tpcs-label,
  .tpcs-details-modal.tpcs-modal-bottom-left  .tpcs-cookie-card .tpcs-label,
  .tpcs-details-modal.tpcs-modal-sidebar-right .tpcs-cookie-card .tpcs-label,
  .tpcs-details-modal.tpcs-modal-sidebar-left  .tpcs-cookie-card .tpcs-label {
    flex-basis: 150px;
  }
}

@media (min-width: 1440px) {
  .tpcs-details-modal.tpcs-modal-bottom-right .tpcs-modal-content,
  .tpcs-details-modal.tpcs-modal-bottom-left  .tpcs-modal-content {
    max-width: 600px; /* a bit wider on very large screens */
  }
}


/* ===== Cookie Details – Smaller typography (desktop-first) ===== */
@media (min-width: 1024px) {
  /* Base font size for the details panel */
  .tpcs-details-modal .tpcs-modal-content { font-size: 13px; }

  /* Heading a bit smaller */
  .tpcs-details-modal .tpcs-modal-header h3 { font-size: 18px; }

  /* Card labels/values and code chip */
  .tpcs-details-modal .tpcs-cookie-card .tpcs-label { font-size: 13px; }
  .tpcs-details-modal .tpcs-cookie-card .tpcs-value { font-size: 13px; }
  .tpcs-details-modal .tpcs-cookie-card code { font-size: 12px; }
}

/* If you also want smaller text on mobile/tablet, uncomment below
.tpcs-details-modal .tpcs-modal-content { font-size: 13px; }
.tpcs-details-modal .tpcs-modal-header h3 { font-size: 17px; }
.tpcs-details-modal .tpcs-cookie-card .tpcs-label { font-size: 12px; }
.tpcs-details-modal .tpcs-cookie-card .tpcs-value { font-size: 13px; }
.tpcs-details-modal .tpcs-cookie-card code { font-size: 12px; }
*/