/**
 * カスタム日付・時刻フォーマットダイアログ
 * Google Sheets風のデザイン
 */

/* オーバーレイ */
.date-format-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.date-format-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ダイアログ本体 */
.date-format-dialog {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 480px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.date-format-overlay.show .date-format-dialog {
    transform: scale(1);
}

/* ダークモード対応 */
[data-theme="dark"] .date-format-dialog {
    background: #2d2d2d;
    color: #e0e0e0;
}

/* ヘッダー */
.date-format-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}

[data-theme="dark"] .date-format-header {
    border-color: #444;
}

.date-format-title {
    font-size: 18px;
    font-weight: 500;
    color: #333;
    margin: 0;
}

[data-theme="dark"] .date-format-title {
    color: #e0e0e0;
}

.date-format-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: background 0.2s;
}

.date-format-close:hover {
    background: #f0f0f0;
}

[data-theme="dark"] .date-format-close {
    color: #aaa;
}

[data-theme="dark"] .date-format-close:hover {
    background: #444;
}

/* フォーマットビルダー */
.date-format-builder {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

[data-theme="dark"] .date-format-builder {
    background: #252525;
    border-color: #444;
}

.date-format-builder select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
    min-width: 80px;
}

[data-theme="dark"] .date-format-builder select {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
}

.date-format-builder .separator {
    color: #666;
    font-size: 16px;
    padding: 0 4px;
}

[data-theme="dark"] .date-format-builder .separator {
    color: #888;
}

.date-format-apply-btn {
    margin-left: auto;
    padding: 8px 20px;
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.date-format-apply-btn:hover {
    background: #1557b0;
}

/* タブ */
.date-format-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

[data-theme="dark"] .date-format-tabs {
    background: #252525;
    border-color: #444;
}

.date-format-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.date-format-tab:hover {
    color: #1a73e8;
}

.date-format-tab.active {
    color: #1a73e8;
    font-weight: 500;
}

.date-format-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #1a73e8;
}

[data-theme="dark"] .date-format-tab {
    color: #888;
}

[data-theme="dark"] .date-format-tab:hover,
[data-theme="dark"] .date-format-tab.active {
    color: #8ab4f8;
}

[data-theme="dark"] .date-format-tab.active::after {
    background: #8ab4f8;
}

/* プレビューリスト */
.date-format-preview-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    max-height: 400px;
}

.date-format-preview-item {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.1s;
}

.date-format-preview-item:hover {
    background: #f0f0f0;
}

.date-format-preview-item.selected {
    background: #e8f0fe;
}

[data-theme="dark"] .date-format-preview-item:hover {
    background: #3a3a3a;
}

[data-theme="dark"] .date-format-preview-item.selected {
    background: #1a3a5c;
}

.date-format-preview-text {
    font-size: 14px;
    color: #333;
    font-family: 'Roboto Mono', monospace;
}

[data-theme="dark"] .date-format-preview-text {
    color: #e0e0e0;
}

/* 期間タブ用 */
.duration-format-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: #e0e0e0;
    margin: 16px 20px;
    border-radius: 4px;
    overflow: hidden;
}

[data-theme="dark"] .duration-format-grid {
    background: #444;
}

.duration-format-cell {
    background: #fff;
    padding: 12px;
    text-align: center;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: background 0.1s;
}

.duration-format-cell:hover {
    background: #f0f0f0;
}

.duration-format-cell.selected {
    background: #e8f0fe;
    color: #1a73e8;
    font-weight: 500;
}

.duration-format-cell.header {
    background: #f8f9fa;
    font-weight: 500;
    cursor: default;
}

[data-theme="dark"] .duration-format-cell {
    background: #2d2d2d;
    color: #e0e0e0;
}

[data-theme="dark"] .duration-format-cell:hover {
    background: #3a3a3a;
}

[data-theme="dark"] .duration-format-cell.selected {
    background: #1a3a5c;
    color: #8ab4f8;
}

[data-theme="dark"] .duration-format-cell.header {
    background: #252525;
}

/* カスタムフォーマット入力 */
.custom-format-section {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
}

[data-theme="dark"] .custom-format-section {
    border-color: #444;
}

.custom-format-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    display: block;
}

[data-theme="dark"] .custom-format-label {
    color: #888;
}

.custom-format-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Roboto Mono', monospace;
}

[data-theme="dark"] .custom-format-input {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
}

.custom-format-input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

/* フォーマットヘルプ */
.format-help-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 20px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    border-top: 1px solid #e0e0e0;
}

[data-theme="dark"] .format-help-toggle {
    color: #888;
    border-color: #444;
}

.format-help-toggle:hover {
    color: #1a73e8;
}

.format-help-content {
    display: none;
    padding: 12px 20px;
    background: #f8f9fa;
    font-size: 12px;
    color: #666;
}

.format-help-content.show {
    display: block;
}

[data-theme="dark"] .format-help-content {
    background: #252525;
    color: #888;
}

.format-help-table {
    width: 100%;
    border-collapse: collapse;
}

.format-help-table th,
.format-help-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

[data-theme="dark"] .format-help-table th,
[data-theme="dark"] .format-help-table td {
    border-color: #444;
}

.format-help-table code {
    background: #e8e8e8;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Roboto Mono', monospace;
}

[data-theme="dark"] .format-help-table code {
    background: #3a3a3a;
}

/* フッター */
.date-format-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
}

[data-theme="dark"] .date-format-footer {
    border-color: #444;
}

.date-format-cancel-btn {
    padding: 8px 16px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: background 0.2s;
}

.date-format-cancel-btn:hover {
    background: #f0f0f0;
}

[data-theme="dark"] .date-format-cancel-btn {
    border-color: #555;
    color: #aaa;
}

[data-theme="dark"] .date-format-cancel-btn:hover {
    background: #3a3a3a;
}

.date-format-insert-btn {
    padding: 8px 20px;
    background: #1a73e8;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.date-format-insert-btn:hover {
    background: #1557b0;
}

.date-format-insert-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}
