/**
 * EatLog Çerez Onayı
 *
 * styles.css'teki tasarım değişkenlerini (--primary-color, --accent-color,
 * --shadow-lg ...) kullanır; kendi paletini tanımlamaz. styles.css yüklenmezse
 * (get mikrositesi gibi) değişkenler için yedek değerler devreye girer.
 */

.cookie-banner,
.cookie-modal {
    --cc-radius: 16px;
    --cc-surface: var(--background, #ffffff);
    --cc-text: var(--text-primary, #1a1a1a);
    --cc-muted: var(--text-secondary, #6b7280);
    --cc-border: var(--border-color, #e5e7eb);
    --cc-primary: var(--primary-color, #000000);
    --cc-accent: var(--accent-color, #FF6B6B);
    font-family: inherit;
    color: var(--cc-text);
}

.cookie-banner[hidden],
.cookie-modal[hidden] {
    display: none;
}

/* ---------------------------------------------------------------- Banner */

.cookie-banner {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    z-index: 1100; /* .navbar 1000 */
    width: calc(100% - 40px);
    max-width: 960px;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem 1.75rem;
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
    box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.18);
    animation: cookie-slide-up 0.35s ease-out;
}

/* Bant açılınca odak programatik olarak buraya taşınır (ekran okuyucu bildirimi
   duysun diye). Kutunun kendisi tıklanabilir bir öğe değil; görünür halka
   yalnızca gerçek kontrollerde gösterilir. */
.cookie-banner:focus,
.cookie-banner:focus-visible {
    outline: none;
}

@keyframes cookie-slide-up {
    from { opacity: 0; transform: translate(-50%, 16px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

.cookie-banner-text {
    flex: 1;
    min-width: 0;
}

.cookie-banner-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--cc-primary);
}

.cookie-banner-desc {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--cc-muted);
    margin: 0;
}

.cookie-banner-desc a {
    color: var(--cc-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cookie-banner-desc a:hover {
    color: var(--cc-accent);
}

.cookie-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Butonlar .btn-download / .btn-cta dilini izler: 12px radius, 600 ağırlık */
.cookie-btn {
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 12px 22px;
    border-radius: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s;
}

.cookie-btn:focus-visible {
    outline: 2px solid var(--cc-accent);
    outline-offset: 2px;
}

.cookie-btn-primary {
    background: var(--cc-primary);
    color: #ffffff;
    box-shadow: var(--shadow, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
}

.cookie-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
}

.cookie-btn-secondary {
    background: var(--cc-surface);
    color: var(--cc-primary);
    border-color: var(--cc-primary);
}

.cookie-btn-secondary:hover {
    transform: translateY(-2px);
}

.cookie-btn-ghost {
    background: transparent;
    color: var(--cc-muted);
    padding: 12px 10px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cookie-btn-ghost:hover {
    color: var(--cc-primary);
}

/* ----------------------------------------------------------------- Modal */

.cookie-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 15, 15, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: cookie-fade-in 0.2s ease-out;
}

@keyframes cookie-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

body.cookie-modal-open {
    overflow: hidden;
}

/* Pencere açılınca odak buraya taşınır; kutu tıklanabilir bir öğe olmadığı
   için halka yalnızca gerçek kontrollerde gösterilir (bkz. .cookie-banner). */
.cookie-modal-card:focus,
.cookie-modal-card:focus-visible {
    outline: none;
}

.cookie-modal-card {
    width: 100%;
    max-width: 560px;
    max-height: min(85vh, 720px);
    display: flex;
    flex-direction: column;
    background: var(--cc-surface);
    border-radius: var(--cc-radius);
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.cookie-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem 1.75rem 1rem;
    border-bottom: 1px solid var(--cc-border);
}

.cookie-modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--cc-primary);
    margin: 0 0 0.35rem;
}

.cookie-modal-header p {
    font-size: 0.85rem;
    color: var(--cc-muted);
    margin: 0;
}

.cookie-modal-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--background-light, #f9fafb);
    color: var(--cc-muted);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.cookie-modal-close:hover {
    color: var(--cc-primary);
}

.cookie-modal-close:focus-visible {
    outline: 2px solid var(--cc-accent);
    outline-offset: 2px;
}

.cookie-modal-body {
    padding: 0.5rem 1.75rem;
    overflow-y: auto;
}

.cookie-category {
    padding: 1.15rem 0;
    border-bottom: 1px solid var(--cc-border);
}

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

.cookie-category-row {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

.cookie-category-text {
    flex: 1;
    min-width: 0;
}

/* Ayrıntılar akordiyonu - çerez tablosunu açar/kapatır */
.cookie-category-expand {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    background: var(--background-light, #f9fafb);
    border: 1px solid var(--cc-border);
    border-radius: 50%;
    color: var(--cc-text);
    cursor: pointer;
    transition: transform 0.3s, background 0.3s;
}

.cookie-category-expand:hover {
    background: var(--cc-border);
}

.cookie-category-expand:focus-visible {
    outline: 2px solid var(--cc-accent);
    outline-offset: 2px;
}

.cookie-category-expand[aria-expanded="true"] {
    transform: rotate(180deg);
}

.cookie-category-panel[hidden] {
    display: none;
}

.cookie-category-panel {
    margin: 1rem 0 0.25rem 2.4rem;
    padding: 1rem 1.1rem;
    background: var(--background-light, #f9fafb);
    border: 1px solid var(--cc-border);
    border-radius: 12px;
}

.cookie-table-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cc-muted);
    margin: 0 0 0.75rem;
}

.cookie-table-empty {
    font-size: 0.825rem;
    color: var(--cc-muted);
    margin: 0;
}

.cookie-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cookie-table-wrap:focus-visible {
    outline: 2px solid var(--cc-accent);
    outline-offset: 2px;
    border-radius: 6px;
}

.cookie-table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    font-size: 0.8rem;
    line-height: 1.5;
    text-align: left;
}

.cookie-table th,
.cookie-table td {
    padding: 0.6rem 0.75rem 0.6rem 0;
    vertical-align: top;
    border-bottom: 1px dashed var(--cc-border);
}

.cookie-table tbody tr:last-child th,
.cookie-table tbody tr:last-child td {
    border-bottom: none;
}

.cookie-table thead th {
    font-weight: 600;
    color: var(--cc-text);
    white-space: nowrap;
}

.cookie-table tbody th {
    width: 30%;
    font-weight: 500;
    color: var(--cc-text);
}

.cookie-table tbody th code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.78rem;
    word-break: break-all;
}

.cookie-table td {
    color: var(--cc-muted);
}

.cookie-table-expiry {
    white-space: nowrap;
}

.cookie-category-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--cc-text);
}

.cookie-category-desc {
    font-size: 0.825rem;
    line-height: 1.55;
    color: var(--cc-muted);
    margin: 0;
}

/* Anahtar: görsel olarak switch, semantik olarak checkbox (klavye + AT uyumlu) */
.cookie-switch {
    position: relative;
    flex-shrink: 0;
    width: 46px;
    height: 26px;
}

.cookie-switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.cookie-switch-track {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 999px;
    transition: background 0.3s;
    pointer-events: none;
}

.cookie-switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s;
}

.cookie-switch input:checked + .cookie-switch-track {
    background: var(--cc-accent);
}

.cookie-switch input:checked + .cookie-switch-track::after {
    transform: translateX(20px);
}

.cookie-switch input:focus-visible + .cookie-switch-track {
    outline: 2px solid var(--cc-accent);
    outline-offset: 3px;
}

/* Zorunlu çerezler: açık ama değiştirilemez anahtar */
.cookie-switch-locked input {
    cursor: not-allowed;
}

.cookie-switch-locked input:disabled + .cookie-switch-track {
    background: var(--cc-border);
}

.cookie-switch-locked .cookie-switch-track::after {
    /* Kapatılamadığını gösteren onay işareti */
    background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
}

.cookie-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.75rem;
    border-top: 1px solid var(--cc-border);
    background: var(--background-light, #f9fafb);
}

.cookie-modal-footer a {
    font-size: 0.825rem;
    color: var(--cc-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cookie-modal-footer a:hover {
    color: var(--cc-primary);
}

/* Footer'daki "Çerez Ayarları" bağlantısı - .footer-column a ile aynı görünür */
.cookie-settings-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: block;
    margin-bottom: 0.75rem;
    text-align: left;
    transition: color 0.3s;
}

.cookie-settings-link:hover {
    color: var(--primary-color, #000000);
}

/* ------------------------------------------------------------ Responsive */

@media (max-width: 768px) {
    .cookie-banner {
        left: 12px;
        right: 12px;
        bottom: 12px;
        transform: none;
        width: auto;
        max-width: none;
        flex-direction: column;
        align-items: stretch;
        gap: 1.25rem;
        padding: 1.25rem;
    }

    @keyframes cookie-slide-up {
        from { opacity: 0; transform: translateY(16px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .cookie-actions {
        flex-wrap: wrap;
    }

    /* Yalnızca banttaki butonlar satırı paylaşır. Kural .cookie-btn-primary'ye
       genel verilirse modal footer'ındaki kaydet butonu da esner ve dikey
       eksende 140px'e büyür. */
    .cookie-actions .cookie-btn-primary,
    .cookie-actions .cookie-btn-secondary {
        flex: 1 1 140px;
    }

    .cookie-actions .cookie-btn-ghost {
        flex: 1 1 100%;
        text-align: center;
    }

    /* Mobilde tercih penceresi tam ekran açılır */
    .cookie-modal {
        padding: 0;
    }

    .cookie-modal-card {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }

    .cookie-modal-body {
        flex: 1;
    }

    .cookie-modal-header,
    .cookie-modal-body,
    .cookie-modal-footer {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .cookie-modal-footer {
        flex-direction: column-reverse;
        align-items: stretch;
        text-align: center;
        /* Tam ekranda footer alt kenarda kalır, güvenli alan payıyla */
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }

    .cookie-modal-footer .cookie-btn {
        flex: 0 0 auto;
        height: 48px;
        padding-top: 0;
        padding-bottom: 0;
    }

    .cookie-category-panel {
        margin-left: 0;
        padding: 0.85rem 0.9rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cookie-banner,
    .cookie-modal,
    .cookie-btn,
    .cookie-switch-track,
    .cookie-switch-track::after {
        animation: none;
        transition: none;
    }
}
