/* a11y: keyboard focus indicator — now in tokens.css (global) */
/* :root variables are now in tokens.css */

body {
    background-color: var(--color-bg-base);
    color: var(--color-text-primary);
    font-family: var(--font-family-base);
    margin: 0;
    min-height: 100dvh;
    overflow-x: hidden;
}

.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-color: var(--color-bg-base);
}

/* Shapes removed as requested */
.shape {
    display: none;
}

.container {
    width: 100%;
    max-width: 800px;
    z-index: 1;
    margin: 2rem auto;
    padding: 0 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

header h1 i {
    color: var(--color-danger);
    /* YouTube Red */
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-bg-surface);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--color-border-default);
    font-size: 0.9rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--color-text-secondary);
}

.running .dot {
    background-color: var(--color-success);
    box-shadow: 0 0 10px var(--color-success);
}

.stopped .dot {
    background-color: var(--color-danger);
}

.card {
    background: var(--color-bg-surface);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--color-border-default);
    margin-bottom: 1.5rem;
    box-shadow: none;
}

.card h2 {
    font-size: 1.25rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 0.75rem;
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

label {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="text"],
input[type="number"] {
    background: var(--color-shadow-default);
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus {
    border-color: var(--color-accent-primary);
}

.control-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn {
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn.primary {
    background-color: var(--color-accent-primary);
    color: white;
}

.btn.primary:hover {
    background-color: var(--color-accent-hover);
}

.btn.secondary {
    background-color: transparent;
    border: 1px solid var(--color-border-light);
    color: var(--color-text-primary);
}

.btn.secondary:hover {
    background-color: var(--color-overlay-light);
}

.btn.small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: var(--color-text-primary);
}

.btn-icon.delete:hover {
    color: var(--color-danger);
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-border-light);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--color-accent-primary);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.switch.small {
    width: 36px;
    height: 20px;
}

.switch.small .slider:before {
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
}

.switch.small input:checked+.slider:before {
    transform: translateX(16px);
}

/* Channel List */
.channel-item {
    display: flex;
    flex-direction: column;
    background: var(--color-shadow-default);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--color-border-default);
    gap: 0.5rem;
}

/* 上段: チャンネル名 + コントロール */
.ch-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.ch-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.ch-name {
    font-weight: 600;
    color: var(--color-text-primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ch-name:visited {
    color: var(--color-text-primary);
}

.ch-name:hover {
    color: var(--color-text-primary);
    text-decoration: underline;
}

.ch-url {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 右側コントロール（トグル＋削除のみ） */
.ch-primary-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* コントロール（Limit, 無視設定, トグル, 削除） */
.ch-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* 下段: 配信情報 */
.ch-stream-section {
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border-default);
}

.add-channel-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.add-channel-form input {
    flex: 1;
}

.active-monitors-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.active-monitors-panel li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border-default);
    color: var(--color-text-secondary);
}

.active-monitors-panel li:last-child {
    border-bottom: none;
}

/* Stream Indicators */
.ch-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
}

.stream-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stream-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.2rem 0;
    overflow: hidden;
    /* Prevent item overflow */
}

.stream-badge {
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    flex-shrink: 0;
    /* Prevent badge shrinking */
}

.status-live {
    background-color: var(--color-danger);
    color: white;
}

.status-upcoming {
    background-color: var(--color-accent-primary);
    color: white;
}

.stream-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    /* Take remaining space */
    min-width: 0;
    /* Critical for text-overflow to work in flex */
}

.stream-link {
    color: var(--color-text-primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    flex: 1;
    /* Allow link to grow but not overflow */
    min-width: 0;
}

.stream-link:hover {
    text-decoration: underline;
    color: var(--color-accent-primary);
}

.btn-report {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-accent-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    text-decoration: none;
    border: 1px solid rgba(59, 130, 246, 0.3);
    transition: all 0.2s;
    flex-shrink: 0;
    /* Prevent button shrinking */
    white-space: nowrap;
}

.btn-report:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--color-accent-primary);
}

.no-stream {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    font-style: italic;
    margin-top: 0.25rem;
}

/* PubSubHubbub Section */
.pubsub-section .description {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    margin-top: -0.5rem;
}

.pubsub-section .hint {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

.pubsub-status-panel,
.fast-probe-status-panel {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--color-border-default);
}

.pubsub-status-panel h4,
.fast-probe-status-panel h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.fast-probe-status-panel .status-item {
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.pubsub-enabled {
    color: var(--color-success);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.pubsub-disabled {
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.webhook-url {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    word-break: break-all;
    margin-bottom: 0.5rem;
}

.sub-count {
    font-size: 0.9rem;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

.sub-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.sub-list li {
    font-size: 0.85rem;
    padding: 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sub-list li.active {
    color: var(--color-success);
}

.sub-list li.expired {
    color: var(--color-text-secondary);
}

.no-subs {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    font-style: italic;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* .sr-only is now in utilities.css */

/* Modal close button reset (span→button visual parity) */
.close-modal-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    line-height: inherit;
}

/* 検知方法バッジ */
.detected-via-pubsub {
    background-color: #059669;
    /* Solid Green */
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 0.5rem;
}

/* ============================================
 * Phase M2: 設定画面モバイルレスポンシブ対応
 * ファイル末尾配置でカスケード競合を回避
 * ============================================ */

/* M2-11: header 縦並び化 */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .status-indicator {
        justify-content: center;
    }
}

/* M2-12: control-buttons 縦並び・全幅化 */
@media (max-width: 768px) {
    .control-buttons {
        flex-direction: column;
    }

    .control-buttons .btn,
    .control-buttons a.btn {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
}

/* M2-14: ch-top-row / ch-controls 折り返し */
@media (max-width: 640px) {
    .ch-top-row {
        flex-wrap: wrap;
    }

    .ch-controls {
        width: 100%;
        justify-content: flex-end;
    }

    .ch-primary-controls {
        width: 100%;
        justify-content: flex-end;
    }
}