/* General Layout */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    display: flex;
    flex-direction: column; /* 让 header, main, footer 垂直排列 */
    min-height: 100vh;
}

.app-header {
    background-color: #333;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
    margin: 0;
    font-size: 1.5em;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 15px; /* 元素之间的间距 */
}

.nav-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
    padding: 5px;
}

.current-date {
    font-size: 1.1em;
}

.date-navigator button {
    background-color: #555;
    color: white;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
}

.app-main {
    flex-grow: 1; /* 让 main 区域填充剩余空间 */
    padding: 20px;
    gap: 20px;
}

.app-grid {
    display: grid;
    grid-template-columns: 340px minmax(420px, 1fr) 420px;
    gap: 20px;
    align-items: start;
}

.left-panel {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.center-panel {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
}

.right-panel {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.app-footer {
    background-color: #333;
    color: #bbb;
    text-align: center;
    padding: 15px 20px;
    font-size: 0.9em;
    margin-top: auto; /* 将 footer 推到底部 */
}

.app-footer p {
    margin: 5px 0;
}

/* Left panel sections */
.panel-section {
    margin-top: 16px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 6px;
}

.panel-section h2 {
    margin: 0 0 10px 0;
    font-size: 1.05em;
}

.form-grid {
    display: grid;
    gap: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 10px;
    align-items: center;
}

.form-label {
    color: #555;
    font-size: 0.9em;
}

.text-input {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95em;
    width: 100%;
    box-sizing: border-box;
}

.color-input {
    width: 48px;
    height: 34px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    padding: 0;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.primary-btn {
    padding: 9px 12px;
    border: none;
    border-radius: 6px;
    background: #007bff;
    color: white;
    font-weight: 600;
    cursor: pointer;
}

.primary-btn:hover {
    background: #0b6fe2;
}

.form-hint {
    color: #777;
    font-size: 0.9em;
    min-height: 1em;
}

.category-list {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.04);
    border-radius: 999px;
    font-size: 0.9em;
}

.category-actions {
    display: inline-flex;
    gap: 6px;
    margin-left: 6px;
}

.category-edit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.text-input.small {
    padding: 6px 8px;
    font-size: 0.9em;
    width: 140px;
}

.color-input.small {
    width: 40px;
    height: 30px;
}

.icon-btn {
    padding: 6px 10px;
    border: 1px solid rgba(0,0,0,0.12);
    background: rgba(255,255,255,0.7);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85em;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.95);
}

.danger-btn {
    padding: 9px 12px;
    border: none;
    border-radius: 6px;
    background: #dc2626;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.danger-btn:hover {
    background: #b91c1c;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: grid;
    place-items: center;
    z-index: 10000;
}

.modal-card {
    width: min(640px, calc(100vw - 24px));
    background: white;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.35);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    background: rgba(0,0,0,0.02);
}

.modal-title {
    font-weight: 800;
    color: #111;
}

.modal-body {
    padding: 14px;
}

.category-swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,0.15);
}

/* Timer Section Styles */
.timer-section {
    margin-top: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.timer-section h2 {
    margin-top: 0;
    font-size: 1.1em;
}

.timer-display {
    font-size: 2.5em;
    font-weight: bold;
    text-align: center;
    font-family: 'Courier New', monospace;
    margin: 15px 0;
    color: #333;
}

.timer-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.category-select {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9em;
}

.timer-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.start-btn {
    background-color: #4CAF50;
    color: white;
}

.start-btn:hover {
    background-color: #45a049;
}

.stop-btn {
    background-color: #f44336;
    color: white;
}

.stop-btn:hover {
    background-color: #da190b;
}

.no-entries-message {
    text-align: center;
    color: #999;
    padding: 10px;
    font-style: italic;
}

/* Center visualization */
.viz-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.viz-tab {
    padding: 6px 10px;
    border: 1px solid #ddd;
    background: #f5f5f5;
    border-radius: 999px;
    cursor: pointer;
}

.viz-tab.active {
    background: #111827;
    color: white;
    border-color: #111827;
}

.viz-title {
    margin-left: auto;
    color: #444;
    font-size: 0.95em;
}

.viz-day {
    display: grid;
    gap: 10px;
}

.day-scale {
    position: relative;
    height: 18px;
}

.day-tick {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    color: #999;
    font-size: 10px;
    white-space: nowrap;
}

.day-bar {
    position: relative;
    height: 64px;
    border-radius: 10px;
    background: linear-gradient(to right, rgba(0,0,0,0.04) 0%, rgba(0,0,0,0.02) 100%);
    border: 1px solid rgba(0,0,0,0.06);
    overflow: hidden;
}

.empty-hint {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #999;
    font-size: 0.95em;
}

.viz-week {
    display: grid;
    gap: 8px;
}

.week-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
}

.week-day-header {
    padding: 6px 8px;
    text-align: center;
    font-size: 0.85em;
    color: #666;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    height: 720px;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 10px;
    overflow: hidden;
}

.week-day {
    position: relative;
    border-right: 1px solid rgba(0,0,0,0.06);
    background:
        linear-gradient(to bottom, rgba(0,0,0,0.06) 1px, transparent 1px) 0 0 / 100% 60px;
}

.week-day:last-child {
    border-right: none;
}

/* Event blocks + hover */
.event-block {
    position: absolute;
    top: 12px;
    bottom: 12px;
    border-radius: 10px;
    color: rgba(255,255,255,0.95);
    padding: 8px 10px;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 2px solid transparent;
    transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
    cursor: default;
}

.event-block.week {
    border-radius: 8px;
    padding: 6px 8px;
    top: auto;
    bottom: auto;
}

.event-block:hover {
    transform: scale(1.04);
    border-color: rgba(255,255,255,0.95);
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
    z-index: 5;
}

.event-label {
    font-size: 0.9em;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

/* Manga-style tooltip */
[x-cloak] { display: none !important; }

.viz-tooltip {
    position: fixed;
    z-index: 9999;
    width: 240px;
    background: rgba(220, 220, 220, 0.78);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.75);
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: 0 14px 30px rgba(0,0,0,0.25);
    pointer-events: none;
}

.viz-tooltip:before {
    content: '';
    position: absolute;
    left: 14px;
    top: -8px;
    width: 14px;
    height: 14px;
    background: rgba(220, 220, 220, 0.78);
    border-left: 1px solid rgba(255,255,255,0.75);
    border-top: 1px solid rgba(255,255,255,0.75);
    transform: rotate(45deg);
}

.tooltip-title {
    font-weight: 800;
    color: #111;
    margin-bottom: 6px;
}

.tooltip-meta {
    color: #222;
    font-size: 0.9em;
    display: grid;
    gap: 4px;
}

.tooltip-meta .k {
    display: inline-block;
    min-width: 3em;
    color: rgba(0,0,0,0.6);
}

/* Dashboard Styles */
.dashboard-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.dashboard-controls button {
    padding: 8px 15px;
    border: 1px solid #ddd;
    background-color: #f0f0f0;
    border-radius: 4px;
    cursor: pointer;
}

.dashboard-controls button.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.chart-container {
    width: 100%;
    max-width: 400px; /* 饼状图通常是正方形或圆形，设置最大宽度 */
    height: 300px; /* 设置高度以确保图表正确显示 */
    margin: 0 auto 30px auto; /* 居中显示 */
}

.summary-table {
    margin-top: 30px;
}

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

.summary-table th, .summary-table td {
    border: 1px solid #eee;
    padding: 8px 12px;
    text-align: left;
}

.summary-table th {
    background-color: #f8f8f8;
    font-weight: bold;
}

/* Responsive Design (Basic) */
@media (max-width: 768px) {
    .app-main {
        display: block;
    }
    .app-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1200px) {
    .app-grid {
        grid-template-columns: 340px 1fr;
        grid-template-areas:
            "left center"
            "right right";
    }
    .left-panel { grid-area: left; }
    .center-panel { grid-area: center; }
    .right-panel { grid-area: right; }
}