/**
 * コマログ - メインスタイルシート
 * テーマカラーはthemes.cssで定義
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-from) 0%, var(--bg-gradient-to) 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 700px;
    margin: 0 auto;
}

.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 30px;
    margin-bottom: 20px;
}

.header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.header svg {
    width: 32px;
    height: 32px;
    color: var(--primary);
    flex-shrink: 0;
}

h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.lead-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* タイマー表示 */
.timer-display {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.timer-time {
    font-size: 48px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    margin-bottom: 20px;
}

/* ボタン */
.btn {
    border: none;
    padding: 16px 40px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: scale(1.05);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-start {
    background: var(--btn-start);
    color: white;
}

.btn-start:hover:not(:disabled) {
    background: var(--btn-start-hover);
}

.btn-stop {
    background: var(--btn-stop);
    color: white;
}

.btn-stop:hover:not(:disabled) {
    background: var(--btn-stop-hover);
}

h2 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* 日別グループ */
.date-group {
    margin-bottom: 20px;
}

.date-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-section);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 8px;
}

.date-header:hover {
    background: var(--bg-session-hover);
}

.date-toggle {
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.date-toggle.collapsed {
    transform: rotate(-90deg);
}

.date-label {
    flex: 1;
    font-weight: bold;
    color: var(--text-primary);
    font-size: 16px;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.date-label-text {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.date-label-text:hover {
    background: var(--primary);
    color: white;
}

.date-input-hidden {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.date-total {
    color: var(--primary);
    font-weight: bold;
    font-size: 14px;
}

.date-sessions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-left: 12px;
}

.date-sessions.collapsed {
    display: none;
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* セッション項目 */
.session-item {
    background: var(--bg-session);
    border-radius: 8px;
    padding: 12px 16px;
    transition: background 0.2s;
}

.session-item:hover {
    background: var(--bg-session-hover);
}

.session-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-info {
    flex: 1;
}

.session-time {
    font-weight: bold;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.session-time-text {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.session-time-text:hover {
    background: var(--primary);
    color: white;
}

.session-time-input-inline {
    width: 90px;
    padding: 2px 6px;
    border: 2px solid var(--primary);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    font-weight: bold;
}

.session-time-input-inline:focus {
    outline: none;
}

.session-duration {
    color: var(--primary);
    font-weight: normal;
    font-size: 13px;
    margin-left: 4px;
}

.session-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.btn-edit-memo {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.6;
}

.btn-edit-memo:hover {
    background: var(--bg-section);
    color: var(--primary);
    opacity: 1;
}

.btn-edit-memo svg {
    width: 16px;
    height: 16px;
}

.btn-duplicate {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.6;
}

.btn-duplicate:hover {
    background: var(--bg-section);
    color: var(--accent);
    opacity: 1;
}

.btn-duplicate svg {
    width: 16px;
    height: 16px;
}

/* メモ編集・複製編集 */
.session-memo-edit {
    margin-top: 8px;
    display: none;
}

.session-memo-edit.active {
    display: block;
}

.session-duplicate-edit {
    margin-top: 8px;
    display: none;
    border-top: 1px dashed var(--border-color);
    padding-top: 12px;
}

.session-duplicate-edit.active {
    display: block;
}

.session-date-input {
    width: 150px;
    padding: 6px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

.session-date-input:focus {
    outline: none;
    border-color: var(--primary);
}

.session-edit-row {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    align-items: center;
}

.session-time-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1;
}

.session-time-input {
    width: 80px;
    padding: 6px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

.session-time-input:focus {
    outline: none;
    border-color: var(--primary);
}

.time-separator {
    color: var(--text-secondary);
    font-weight: bold;
}

.session-memo-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.session-memo-input:focus {
    outline: none;
    border-color: var(--primary);
}

.session-memo-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn-memo-save,
.btn-memo-cancel {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-memo-save {
    background: var(--primary);
    color: white;
}

.btn-memo-save:hover {
    background: var(--primary-dark);
}

.btn-memo-cancel {
    background: var(--bg-section);
    color: var(--text-secondary);
}

.btn-memo-cancel:hover {
    background: var(--border-color);
}

.session-memo-display {
    margin-top: 6px;
    padding: 8px 12px;
    background: var(--bg-section);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
}

.btn-delete {
    background: none;
    border: none;
    color: var(--btn-delete);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-delete:hover {
    background: var(--btn-delete-hover);
}

.btn-delete svg {
    width: 20px;
    height: 20px;
}

/* ステート表示 */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
}

.footer {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #6b7280;
}

/* 右上ボタン群 */
.top-buttons {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 1000;
}

/* 設定関連のスタイル */
.settings-icon,
.summary-icon {
    background: var(--bg-card);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.settings-icon:hover {
    transform: rotate(90deg);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.summary-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.settings-icon svg,
.summary-icon svg {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

/* 月次サマリーポップアップ */
.summary-popup {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 280px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.summary-popup.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.summary-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.summary-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.summary-close:hover {
    background: var(--hover-bg);
}

.summary-close svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.summary-content {
    padding: 16px 20px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.summary-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

.settings-panel {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100vh;
    background: var(--bg-card);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
    padding: 24px;
}

.settings-panel.open {
    right: 0;
}

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 1000;
}

.settings-overlay.show {
    display: block;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.settings-header h3 {
    font-size: 20px;
    color: var(--text-primary);
}

.settings-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-secondary);
}

.settings-close svg {
    width: 24px;
    height: 24px;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h4 {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.theme-options {
    display: grid;
    gap: 8px;
}

.theme-option {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-option:hover {
    border-color: var(--primary);
    background: var(--bg-section);
}

.theme-option.active {
    border-color: var(--primary);
    background: var(--bg-section);
    font-weight: bold;
}

.theme-color-preview {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.theme-name {
    flex: 1;
    color: var(--text-primary);
}

/* レスポンシブ */
@media (max-width: 640px) {
    body {
        padding: 10px;
    }

    .card {
        padding: 20px;
    }

    .timer-display {
        padding: 30px 20px;
    }

    .timer-time {
        font-size: 36px;
    }

    h1 {
        font-size: 22px;
    }

    .lead-text {
        font-size: 12px;
    }

    .settings-panel {
        width: 100%;
        right: -100%;
    }

    .top-buttons {
        top: 10px;
        right: 10px;
        gap: 8px;
    }

    .settings-icon,
    .summary-icon {
        width: 40px;
        height: 40px;
    }

    .settings-icon svg,
    .summary-icon svg {
        width: 20px;
        height: 20px;
    }

    .summary-popup {
        top: 60px;
        right: 10px;
        width: calc(100% - 20px);
        max-width: 320px;
    }
}
