/**
 * Cookie同意バナーとモーダルのスタイル
 */

/* Cookie同意バナー */
.cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-color, #ffffff);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.cookie-consent-banner.show {
    transform: translateY(0);
}

.cookie-consent-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.cookie-consent-text {
    flex: 1;
    min-width: 300px;
}

.cookie-consent-text h3 {
    margin: 0 0 10px;
    font-size: 1.2rem;
    color: var(--text-color, #333);
}

.cookie-consent-text p {
    margin: 0 0 10px;
    color: var(--text-secondary, #666);
    line-height: 1.5;
}

.cookie-policy-link {
    color: var(--primary-color, #0066cc);
    text-decoration: none;
    font-size: 0.9rem;
}

.cookie-policy-link:hover {
    text-decoration: underline;
}

.cookie-consent-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: stretch;
}

.cookie-consent-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: normal;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    box-sizing: border-box;
}

.cookie-accept-all {
    background: var(--primary-color, #0066cc);
    color: white;
}

.cookie-accept-all:hover {
    background: var(--primary-dark, #0052a3);
}

.cookie-customize {
    background: transparent;
    color: var(--primary-color, #0066cc);
    border: 2px solid var(--primary-color, #0066cc);
}

.cookie-customize:hover {
    background: var(--primary-color, #0066cc);
    color: white;
}

.cookie-reject-all {
    background: var(--gray-light, #f0f0f0);
    color: var(--text-color, #333);
}

.cookie-reject-all:hover {
    background: var(--gray-medium, #e0e0e0);
}

/* Cookie設定モーダル */
.cookie-consent-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s;
    padding: 20px;
}

.cookie-consent-modal.show {
    opacity: 1;
}

.cookie-consent-modal-content {
    background: var(--surface-color, white);
    border-radius: 10px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.cookie-consent-modal-content h2 {
    margin: 0 0 10px;
    color: var(--text-color, #333);
}

.cookie-consent-modal-content>p {
    margin: 0 0 30px;
    color: var(--text-secondary, #666);
}

/* Cookie カテゴリー */
.cookie-category {
    margin-bottom: 25px;
    padding: 20px;
    background: var(--bg-light, #f8f9fa);
    border-radius: 8px;
}

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

.cookie-category h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-color, #333);
}

.cookie-category>p {
    margin: 0 0 10px;
    color: var(--text-secondary, #666);
    font-size: 0.95rem;
}

.cookie-category details {
    margin-top: 10px;
}

.cookie-category summary {
    cursor: pointer;
    color: var(--primary-color, #0066cc);
    font-size: 0.9rem;
    outline: none;
}

.cookie-category details[open] summary {
    margin-bottom: 10px;
}

.cookie-category ul {
    margin: 0;
    padding-left: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary, #666);
}

/* Cookie トグルスイッチ */
.cookie-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.cookie-switch.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.cookie-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-medium, #ccc);
    transition: 0.3s;
    border-radius: 28px;
}

.cookie-switch .slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.cookie-switch input:checked+.slider {
    background-color: var(--success-color, #28a745);
}

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

.cookie-switch.disabled .slider {
    cursor: not-allowed;
}

/* モーダルボタン */
.cookie-consent-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
}

.cookie-save-preferences {
    background: var(--primary-color, #0066cc);
    color: white;
}

.cookie-save-preferences:hover {
    background: var(--primary-dark, #0052a3);
}

.cookie-modal-close {
    background: var(--gray-light, #f0f0f0);
    color: var(--text-color, #333);
}

.cookie-modal-close:hover {
    background: var(--gray-medium, #e0e0e0);
}

/* Cookie設定リンク */
.cookie-settings-link {
    color: var(--text-secondary, #666);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
}

.cookie-settings-link:hover {
    color: var(--primary-color, #0066cc);
    text-decoration: underline;
}

/* ダークモード対応 */
body.dark-mode .cookie-consent-banner {
    background: var(--dark-surface, #2d2d2d);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

body.dark-mode .cookie-consent-modal-content {
    background: var(--dark-surface, #2d2d2d);
}

body.dark-mode .cookie-category {
    background: var(--dark-bg-light, #3d3d3d);
}

body.dark-mode .cookie-reject-all,
body.dark-mode .cookie-modal-close {
    background: var(--dark-gray-light, #4d4d4d);
    color: var(--dark-text, #e0e0e0);
}

body.dark-mode .cookie-reject-all:hover,
body.dark-mode .cookie-modal-close:hover {
    background: var(--dark-gray-medium, #5d5d5d);
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .cookie-consent-banner {
        padding: 15px;
    }

    .cookie-consent-text h3 {
        font-size: 1.1rem;
    }

    .cookie-consent-text p {
        font-size: 0.9rem;
    }

    .cookie-consent-buttons {
        gap: 8px;
    }

    .cookie-consent-content {
        flex-direction: column;
        gap: 20px;
    }

    .cookie-consent-text {
        min-width: auto;
    }

    .cookie-consent-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .cookie-consent-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        max-width: 100%;
        padding: 10px 8px;
        font-size: 0.8rem;
        word-break: break-word;
        overflow-wrap: break-word;
        -webkit-hyphens: auto;
        hyphens: auto;
    }

    /* 3つ目のボタンは全幅 */
    .cookie-consent-btn:nth-child(3) {
        flex: 1 1 100%;
    }

    .cookie-consent-modal-content {
        padding: 20px;
    }

    .cookie-category {
        padding: 15px;
    }
}

/* (390px) および一般的なスマートフォン用 */
@media (max-width: 480px) {
    .cookie-consent-banner {
        padding: 12px;
    }

    .cookie-consent-content {
        gap: 15px;
    }

    .cookie-consent-text h3 {
        font-size: 1rem;
        margin-bottom: 5px;
    }

    .cookie-consent-text p {
        font-size: 0.85rem;
        margin-bottom: 5px;
    }

    .cookie-consent-buttons {
        gap: 6px;
        justify-content: space-between;
    }

    .cookie-consent-btn {
        flex: 0 0 auto;
        padding: 8px 10px;
        font-size: 0.75rem;
        min-height: 36px;
        letter-spacing: -0.02em;
    }

    /* 「すべて受け入れる」を短縮 */
    .cookie-accept-all {
        flex: 0 0 calc(45% - 3px);
    }

    /* 「カスタマイズ」を短縮 */
    .cookie-customize {
        flex: 0 0 calc(35% - 3px);
    }

    /* 「必須のみ」はさらに短く */
    .cookie-reject-all {
        flex: 0 0 calc(20% - 3px);
        font-size: 0.7rem;
        padding: 8px 6px;
    }
}

/* 極小画面用 (375px以下) */
@media (max-width: 375px) {
    .cookie-consent-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .cookie-consent-btn {
        width: 100%;
        min-height: 40px;
        font-size: 0.8rem;
        padding: 8px 10px;
    }

    /* 最初の2つのボタンを優先表示 */
    .cookie-consent-btn.cookie-accept-all {
        order: 1;
    }

    .cookie-consent-btn.cookie-reject-all {
        order: 2;
        font-size: 0.75rem;
    }

    .cookie-consent-btn.cookie-customize {
        order: 3;
    }
}