/* ===========================
   Unified Toggle Switch Component
   すべてのトグルスイッチの統一スタイル
   =========================== */

/* Base Toggle Container */
.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.toggle-group:hover {
    background: #f0f4f8;
    border-color: #e2e8f0;
}

/* Toggle Info Section */
.toggle-info {
    flex: 1;
    margin-right: 24px;
}

.toggle-info strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.toggle-info p {
    font-size: 14px;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
}

/* Toggle Switch Container - 統一版 */
.toggle-switch {
    position: relative;
    display: inline-block;
    min-width: 56px;
    height: 32px;
    flex-shrink: 0;
}

/* Hide default checkbox */
.toggle-switch input[type="checkbox"],
.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Toggle Slider Track */
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 34px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Toggle Slider Circle - 単一の丸のみ */
.toggle-slider::before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Active State */
.toggle-input:checked + .toggle-slider,
.toggle-switch input:checked + .toggle-slider {
    background-color: #0066ff;
    box-shadow: inset 0 2px 4px rgba(0, 102, 255, 0.2);
}

/* Move circle when checked */
.toggle-input:checked + .toggle-slider::before,
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* Focus State */
.toggle-input:focus + .toggle-slider,
.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.2);
}

/* Loading State */
.toggle-switch.loading .toggle-slider {
    opacity: 0.6;
    cursor: not-allowed;
}

.toggle-switch.loading .toggle-slider::before {
    animation: pulse 1s infinite;
}

/* Old .active class support (移行用) */
.toggle-switch.active {
    /* 空のルール - 新しい実装では不要 */
}

/* Remove any ::after pseudo elements that might create double circles */
.toggle-switch::after,
.toggle-slider::after {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .toggle-group {
        padding: 16px;
    }
    
    .toggle-info {
        margin-right: 16px;
    }
    
    .toggle-info strong {
        font-size: 15px;
    }
    
    .toggle-info p {
        font-size: 13px;
    }
    
    .toggle-switch {
        min-width: 48px;
        height: 28px;
    }
    
    .toggle-slider::before {
        height: 20px;
        width: 20px;
        left: 4px;
        bottom: 4px;
    }
    
    .toggle-input:checked + .toggle-slider::before,
    .toggle-switch input:checked + .toggle-slider::before {
        transform: translateX(20px);
    }
}

@media (max-width: 480px) {
    .toggle-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .toggle-info {
        margin-right: 0;
        width: 100%;
    }
    
    .toggle-switch {
        align-self: flex-end;
    }
}

/* Animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Accessibility */
.toggle-switch:focus-within {
    outline: 2px solid #0066ff;
    outline-offset: 2px;
}

/* Disabled State */
.toggle-switch.disabled,
.toggle-switch[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-switch.disabled .toggle-slider,
.toggle-switch[disabled] .toggle-slider {
    cursor: not-allowed;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .toggle-group {
        background: #1a1a1a;
        border-color: #2a2a2a;
    }
    
    .toggle-group:hover {
        background: #2a2a2a;
        border-color: #3a3a3a;
    }
    
    .toggle-info strong {
        color: #e0e0e0;
    }
    
    .toggle-info p {
        color: #a0a0a0;
    }
    
    .toggle-slider {
        background-color: #4a4a4a;
    }
    
    .toggle-input:checked + .toggle-slider,
    .toggle-switch input:checked + .toggle-slider {
        background-color: #0066ff;
    }
}