/* 
 * TZQ Unified Modal System (Master Bundle)
 * Targets: Frontend Quiz Modals, Admin Dashboard Modals, Badge/Achievement Modals.
 * Design: Vibrant Minimalist v4.0 (Glassmorphism & Smooth Scaling)
 */

:root {
    --tzq-modal-z: var(--tzq-z-modal, 100000);
    --tzq-modal-overlay: rgba(15, 23, 42, 0.65);
    --tzq-modal-bg: rgba(255, 255, 255, 0.95);
    --tzq-modal-radius: 1.5rem;
    --tzq-modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

/* ── Base Layer ── */
.tzq-modal, 
.modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 100000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.tzq-modal--active, 
.tzq-modal.is-active,
.tzq-modal.show, 
.modal.show,
.modal.in {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ── Overlay Layer (Minimalist) ── */
.tzq-modal-overlay, 
.tzq-modal__overlay, 
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.5) !important;
    z-index: -1;
    opacity: 0;
}

.tzq-modal--active .tzq-modal__overlay,
.modal.show .modal-backdrop,
.modal-open .modal-backdrop {
    opacity: 1;
}

.modal-backdrop { z-index: calc(var(--tzq-modal-z) - 1) !important; display: block !important; }

/* ── Container Layer (Minimalist Animation) ── */
.tzq-modal-content, 
.tzq-modal__content,
.tzq-modal__container, 
.modal-content,
.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 95%;
    margin: 0 auto;
    background: #ffffff;
    border-radius: var(--tzq-spacing-xs);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 1;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    transform: translateY(20px);
    opacity: 0;
}

.tzq-modal--active .tzq-modal-content,
.tzq-modal--active .tzq-modal__content,
.tzq-modal--active .tzq-modal__container,
.tzq-modal.is-active .tzq-modal-content,
.tzq-modal.is-active .tzq-modal__content,
.tzq-modal.is-active .tzq-modal__container,
.modal.show .modal-content,
.modal.show .modal-dialog {
    transform: translateY(0);
    opacity: 1;
}

/* ── Header Layer ── */
.tzq-modal-header, 
.tzq-modal__header, 
.modal-header {
    padding: 1.5rem 2rem;
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.tzq-modal__title, 
.tzq-modal-title,
.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--tzq-text-primary, #1e293b);
    letter-spacing: -0.02em;
    font-family: var(--tzq-font-heading, inherit);
}

/* ── Close Button ── */
.tzq-modal-close, 
.tzq-modal__close,
.btn-close,
.modal-header .close,
.btn-close-white {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: var(--tzq-text-secondary, #64748b);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    margin: 0;
    text-shadow: none;
}
.btn-close::before, .modal-header .close::before {
    content: "✖";
    font-family: sans-serif;
    font-size: 14px;
}

.tzq-modal-close:hover, 
.tzq-modal__close:hover,
.btn-close:hover,
.modal-header .close:hover {
    background: var(--tzq-error, #ef4444);
    color: #fff;
    transform: rotate(90deg) scale(1.1);
}

/* ── Body Layer ── */
.tzq-modal-body, 
.tzq-modal__body, 
.modal-body {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
    background: transparent;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--tzq-text-secondary, #4b5563);
}

/* Scrollbar customization for modal body */
.modal-body::-webkit-scrollbar,
.tzq-modal__body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track,
.tzq-modal__body::-webkit-scrollbar-track {
    background: transparent;
}
.modal-body::-webkit-scrollbar-thumb,
.tzq-modal__body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--tzq-spacing-xs);
}
.modal-body::-webkit-scrollbar-thumb:hover,
.tzq-modal__body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ── Footer Layer ── */
.tzq-modal-footer, 
.tzq-modal__footer, 
.modal-footer {
    padding: 1.25rem 2rem;
    background: rgba(248, 250, 252, 0.8);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ── Form Elements inside Modal (Polyfill for Removed Bootstrap) ── */
.modal-body .form-label, .modal-body label {
    display: block;
    font-weight: 700;
    color: var(--tzq-text-primary, #1e293b);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.modal-body .form-control, .modal-body select, .modal-body input[type="text"], .modal-body input[type="number"], .modal-body textarea {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--tzq-border-light, #e2e8f0);
    border-radius: var(--tzq-spacing-xs);
    font-size: 1rem;
    background: #fff;
    color: var(--tzq-text-primary, #1e293b);
    box-sizing: border-box;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

.modal-body .form-control:focus, .modal-body input:focus, .modal-body textarea:focus {
    border-color: var(--tzq-primary, #2563eb);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    outline: none;
}

.modal-body .mb-3 {
    margin-bottom: 1.5rem;
}

.modal-body .input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}
.modal-body .input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex: 1;
}

/* Polyfill for Bootstrap Buttons */
.modal .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: var(--tzq-spacing-xs);
    cursor: pointer;
    border: 1px solid transparent;
}
.modal .btn-primary { background: var(--tzq-primary, #2563eb); color: #fff; box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2); }
.modal .btn-primary:hover { background: #1d4ed8; transform: translateY(-1px); }
.modal .btn-secondary { background: #64748b; color: #fff; }
.modal .btn-secondary:hover { background: #475569; }
.modal .btn-success { background: var(--tzq-success, #10b981); color: #fff; }
.modal .btn-success:hover { background: #059669; }
.modal .btn-danger { background: var(--tzq-error, #ef4444); color: #fff; }
.modal .btn-danger:hover { background: #dc2626; }
.modal .btn-outline-secondary { background: transparent; border-color: #cbd5e1; color: #475569; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.modal .btn-outline-secondary:hover { background: #f1f5f9; }

/* ── Tables inside Modal ── */
.modal-body .table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}
.modal-body .table th {
    background: rgba(248, 250, 252, 0.5);
    padding: 1rem;
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--tzq-text-muted, #64748b);
    border-bottom: 2px solid rgba(0,0,0,0.05);
}
.modal-body .table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 0.9rem;
    vertical-align: middle;
}

/* ── Specific Modals Styling ── */
#tzqHtmlExportModal .modal-header {
    background: var(--tzq-gradient-warning, linear-gradient(135deg, #f59e0b, #d97706)) !important;
    color: #fff !important;
    border-bottom: none;
}
#tzqHtmlExportModal .modal-title { color: #fff; }
#tzqHtmlExportModal .btn-close { filter: brightness(0) invert(1); background-color: rgba(255, 255, 255, 0.2); }

#tzqQuestionsModal .modal-header,
#tzqQuestionModal .modal-header,
#tzqQuizModal .modal-header {
    background: var(--tzq-gradient-primary, linear-gradient(135deg, #2563eb, #1e40af)) !important;
    color: #fff !important;
    border-bottom: none;
}
#tzqQuestionsModal .modal-title,
#tzqQuestionModal .modal-title,
#tzqQuizModal .modal-title { color: #fff; }
#tzqQuestionsModal .btn-close,
#tzqQuestionModal .btn-close,
#tzqQuizModal .btn-close { filter: brightness(0) invert(1); background-color: rgba(255, 255, 255, 0.2); }

#tzqConfirmModal .modal-content {
    border-radius: var(--tzq-spacing-xs);
    border: none;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ── Badge Modal Integration ── */
.tzq-badge-modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 100000; 
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.tzq-badge-modal--active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.tzq-badge-modal__overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    z-index: 1;
}

.tzq-badge-modal__content {
    position: relative;
    width: 90%;
    max-width: 400px;
    background: #ffffff;
    border-radius: var(--tzq-spacing-xs);
    padding: 3rem 2rem !important;
    z-index: 2;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px);
    opacity: 0;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.tzq-badge-modal--active .tzq-badge-modal__content {
    transform: translateY(0);
    opacity: 1;
}

.tzq-badge-modal__meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tzq-badge-modal__date {
    font-size: 0.75rem;
    color: var(--tzq-text-muted, #94a3b8);
    font-weight: 600;
}

.tzq-badge-progress {
    margin-bottom: 2rem;
    background: #f8fafc;
    padding: 1.25rem;
    border-radius: var(--tzq-spacing-xs);
    border: 1px solid #f1f5f9;
}

.tzq-badge-progress__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.tzq-badge-progress__label {
    font-size: 0.7rem;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.05em;
}

.tzq-badge-progress__value {
    font-size: 0.8rem;
    font-weight: 800;
    color: #1e293b;
}

.tzq-badge-progress__bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: var(--tzq-spacing-xs);
    overflow: hidden;
}

.tzq-badge-progress__fill {
    height: 100%;
    background: var(--tzq-primary, #2563eb);
    border-radius: var(--tzq-spacing-xs);
}

.tzq-badge-modal__footer {
    margin-top: 1rem;
}

.tzq-badge-modal__shimmer {
    display: none;
}

.tzq-badge-modal__icon-wrapper {
    width: 120px; height: 120px; margin: 0 auto 1.5rem; display: flex; align-items: center; justify-content: center;
    font-size: 4rem; background: #f8fafc; border-radius: var(--tzq-spacing-xs);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}
.tzq-badge-modal--active .tzq-badge-modal__icon-wrapper { animation: tzqBadgePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
@keyframes tzqBadgePop { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.tzq-badge-modal__title { font-size: 1.75rem; font-weight: 900; margin: 0 0 0.5rem; color: #1e293b; letter-spacing: -0.02em; }
.tzq-badge-modal__description { font-size: 0.9375rem; line-height: 1.5; margin: 0 0 1.25rem; color: #64748b; }
.tzq-badge-modal__xp-badge { display: inline-flex; padding: 0.4rem 1rem; background: var(--tzq-primary-light, #dbeafe); color: var(--tzq-primary, #2563eb); border-radius: var(--tzq-spacing-xs); font-weight: 800; font-size: 0.85rem; }
.tzq-badge-modal__close:hover { background: #ef4444; color: #fff; }

/* ── Size Modifiers ── */
.modal-xl, .tzq-modal--xl { width: 1140px !important; max-width: 95% !important; }
.modal-lg, .tzq-modal--lg, .tzq-modal__content--large, .tzq-modal__container--large { width: 800px !important; max-width: 95% !important; }
.modal-md, .tzq-modal--md, .tzq-modal__content--medium, .tzq-modal__container--medium { width: 600px !important; max-width: 95% !important; }
.modal-sm, .tzq-modal--sm { width: 400px !important; max-width: 95% !important; }

/* ── Responsive Layer ── */
@media (max-width: 768px) {
    .tzq-modal-content, .tzq-modal__container, .modal-content, .modal-dialog { width: 92%; border-radius: var(--tzq-spacing-xs); margin: auto; }
    .tzq-modal-header, .modal-header { padding: 1.25rem 1.5rem; }
    .tzq-modal-body, .modal-body { padding: 1.5rem; }
    .tzq-modal-footer, .modal-footer { padding: 1rem 1.5rem; flex-direction: column-reverse; }
    .tzq-modal-footer .btn { width: 100%; margin-bottom: 0.5rem; }
}

/* ── Admin Dashboard Specific Fixes ── */
.wp-admin .modal-backdrop { z-index: 99998 !important; }
.wp-admin .modal { z-index: 99999 !important; }

/* ==========================================================================
   ÇEREZ BANNER — Sayfanın altında sabit bar
   ========================================================================== */

/* Sayfanın altında sabit — sadece kendi boyutunda */
.tzq-cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    display: none;
    justify-content: center;
    padding: 0 1rem 1rem;
    pointer-events: none;
}

.tzq-cookie-banner.tzq-cookie-banner--visible {
    display: flex;
    pointer-events: auto;
}

/* Kart */
.tzq-cookie-banner__card {
    background: #fff;
    border-radius: var(--tzq-spacing-xs);
    box-shadow:
        0 -8px 32px rgba(15, 23, 42, 0.12),
        0 -2px 8px rgba(15, 23, 42, 0.06),
        0 0 0 1px rgba(15, 23, 42, 0.04);
    padding: 1.25rem 1.5rem;
    max-width: 900px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    pointer-events: auto;
    transform: translateY(100%);
    opacity: 0;
    position: relative;
    overflow: hidden;
}

/* Üst gradient şerit */
.tzq-cookie-banner__card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--tzq-primary, #2563eb), var(--tzq-secondary, #4ecdc4));
    border-radius: var(--tzq-spacing-xs);
}

.tzq-cookie-banner.tzq-cookie-banner--visible .tzq-cookie-banner__card {
    transform: translateY(0);
    opacity: 1;
}

.tzq-cookie-banner__icon {
    font-size: 2rem;
    flex-shrink: 0;
    line-height: 1;
}

.tzq-cookie-banner__text {
    flex: 1;
    min-width: 200px;
}

.tzq-cookie-banner__title {
    font-size: 1rem;
    font-weight: 800;
    margin: 0 0 0.3rem;
    color: var(--tzq-slate-900, #0f172a);
}

.tzq-cookie-banner__desc {
    font-size: 0.8125rem;
    color: var(--tzq-slate-500, #64748b);
    margin: 0;
    line-height: 1.55;
}

.tzq-cookie-banner__desc a {
    color: var(--tzq-primary, #6366f1);
    text-decoration: underline;
    font-weight: 600;
}

.tzq-cookie-banner__actions {
    display: flex;
    gap: 0.625rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
}

.tzq-cookie-btn {
    padding: 0.5625rem 1.25rem;
    border-radius: var(--tzq-spacing-xs);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    white-space: nowrap;
    line-height: 1.2;
}

.tzq-cookie-btn:hover {
    transform: translateY(-2px);
}

.tzq-cookie-btn--accept {
    background: var(--tzq-primary, #6366f1);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.tzq-cookie-btn--accept:hover {
    background: var(--tzq-primary-dark, #4f46e5);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.45);
}

.tzq-cookie-btn--reject {
    background: var(--tzq-slate-100, #f1f5f9);
    color: var(--tzq-slate-700, #334155);
    border: 1px solid var(--tzq-slate-200, #e2e8f0);
}

.tzq-cookie-btn--reject:hover {
    background: var(--tzq-slate-200, #e2e8f0);
}

.tzq-cookie-btn--settings {
    background: transparent;
    color: var(--tzq-slate-400, #94a3b8);
    font-size: 0.8rem;
    padding: 0.5rem 0.625rem;
    text-decoration: underline;
    border: none;
    cursor: pointer;
}

.tzq-cookie-btn--settings:hover {
    color: var(--tzq-primary, #6366f1);
    transform: none;
}

/* ==========================================================================
   MOBİL UYUM (Çerez)
   ========================================================================== */

@media (max-width: 991px) {
    /* Çerez banner — mobil */
    .tzq-cookie-banner {
        padding: 0;
        bottom: 82px; /* App bar height (72px) + bottom offset (10px) */
    }

    .tzq-cookie-banner__card {
        border-radius: var(--tzq-spacing-xs);
        padding: 1rem 1.25rem;
        gap: 0.875rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .tzq-cookie-banner__actions {
        width: 100%;
    }

    .tzq-cookie-btn--accept,
    .tzq-cookie-btn--reject {
        flex: 1;
        text-align: center;
    }
}

/* ==========================================================================
   ÇEREZ TERCİH MODAL — Toggle Switch + Pref Items
   ========================================================================== */

.tzq-cookie-pref-item {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--tzq-slate-100, #f1f5f9);
}

.tzq-cookie-pref-item:last-of-type {
    border-bottom: none;
}

.tzq-cookie-pref-item__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.tzq-cookie-pref-item__title {
    font-size: 0.9375rem;
    font-weight: 800;
    color: var(--tzq-slate-800, #1e293b);
    margin: 0 0 0.375rem;
}

.tzq-cookie-pref-item__desc {
    font-size: 0.8125rem;
    color: var(--tzq-slate-500, #64748b);
    margin: 0;
    line-height: 1.5;
    max-width: 420px;
}

/* "Her Zaman Açık" etiketi */
.tzq-cookie-toggle--disabled {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--tzq-green-600, #16a34a);
    background: var(--tzq-green-50, #f0fdf4);
    border: 1px solid var(--tzq-green-200, #bbf7d0);
    padding: 0.25rem 0.625rem;
    border-radius: var(--tzq-spacing-xs);
    white-space: nowrap;
    margin-top: 2px;
}

/* Toggle switch */
.tzq-cookie-toggle__label {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
    cursor: pointer;
}

.tzq-cookie-toggle__input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.tzq-cookie-toggle__slider {
    position: absolute;
    inset: 0;
    background: var(--tzq-slate-300, #cbd5e1);
    border-radius: var(--tzq-spacing-xs);
}

.tzq-cookie-toggle__slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.tzq-cookie-toggle__input:checked + .tzq-cookie-toggle__slider {
    background: var(--tzq-primary, #6366f1);
}

.tzq-cookie-toggle__input:checked + .tzq-cookie-toggle__slider::before {
    transform: translateX(20px);
}

.tzq-cookie-toggle__input:focus-visible + .tzq-cookie-toggle__slider {
    outline: 2px solid var(--tzq-primary, #6366f1);
    outline-offset: 2px;
}

/* Not */
.tzq-cookie-pref-note {
    font-size: 0.8rem;
    color: var(--tzq-slate-500, #64748b);
    margin: 1rem 0 0;
    padding: 0.75rem;
    background: var(--tzq-slate-50, #f8fafc);
    border-radius: var(--tzq-spacing-xs);
    border: 1px solid var(--tzq-slate-200, #e2e8f0);
    line-height: 1.5;
}

.tzq-cookie-pref-note a {
    color: var(--tzq-primary, #6366f1);
    font-weight: 600;
}
