/* Timer pause/resume history dropdown (js/components/timerHistory.js) */

.th-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 999px;
    padding: 0.3rem 0.55rem;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.th-toggle:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}

.th-toggle:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.th-toggle.is-open {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.th-toggle--icon {
    border-radius: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    gap: 0;
}

.th-toggle--icon .th-chevron {
    display: none;
}

/* The Time Entries page sets "#entries-list * { overflow-x: hidden }" on
   mobile, which turns every element there into a tiny scroll box. */
.th-toggle,
.th-toggle > span,
#entries-list .th-toggle,
#entries-list .th-toggle > span {
    overflow: visible !important;
    white-space: nowrap;
}

.th-icon {
    width: 14px;
    height: 14px;
    flex: none;
}

.th-chevron {
    width: 10px;
    height: 10px;
    flex: none;
    transition: transform 0.2s ease;
}

.th-toggle.is-open .th-chevron {
    transform: rotate(180deg);
}

/* Panel */

.th-wrap {
    width: 100%;
}

.th-wrap[hidden],
.th-row[hidden] {
    display: none !important;
}

.th-panel {
    margin-top: 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    animation: th-reveal 0.18s ease-out;
    text-align: left;
}

.th-row > td {
    padding-top: 0 !important;
    background: #f8fafc;
}

.th-row .th-panel {
    margin: 0.25rem 0 0.75rem;
    max-width: 560px;
}

@keyframes th-reveal {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

/* Summary strip */

.th-summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid #f1f5f9;
    background: #f8fafc;
}

.th-summary--running { background: #f0fdf4; border-bottom-color: #dcfce7; }
.th-summary--paused { background: #fffbeb; border-bottom-color: #fef3c7; }
.th-summary--saved { background: #eff6ff; border-bottom-color: #dbeafe; }

.th-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: none;
    background: #94a3b8;
}

.th-summary--running .th-status-dot {
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    animation: th-pulse 2s infinite;
}

.th-summary--paused .th-status-dot { background: #f59e0b; }
.th-summary--saved .th-status-dot { background: #3b82f6; }

@keyframes th-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.th-status {
    flex: 1;
    min-width: 0;
}

.th-status-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.th-status-sub {
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.4;
    margin-top: 1px;
}

.th-total {
    text-align: right;
    flex: none;
    line-height: 1.2;
}

.th-total span {
    display: block;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
}

.th-total strong {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
}

/* Timeline */

.th-timeline {
    list-style: none;
    margin: 0;
    padding: 0.35rem 0.8rem 0.5rem;
    max-height: 280px;
    overflow-y: auto;
}

.th-day {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 0.5rem 0 0.2rem;
}

.th-event {
    position: relative;
    display: grid;
    grid-template-columns: 12px 4.6rem 1fr;
    grid-template-areas: "dot time label" ". . meta";
    column-gap: 0.5rem;
    align-items: baseline;
    padding: 0.28rem 0;
    font-size: 0.78rem;
}

@media (min-width: 480px) {
    .th-event {
        grid-template-columns: 12px 4.6rem auto 1fr;
        grid-template-areas: "dot time label meta";
    }
}

.th-dot {
    grid-area: dot;
    align-self: center;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    box-shadow: 0 0 0 2px #fff;
    justify-self: center;
}

.th-time {
    grid-area: time;
    font-variant-numeric: tabular-nums;
    color: #334155;
    font-weight: 600;
    white-space: nowrap;
}

.th-label {
    grid-area: label;
    color: #0f172a;
    font-weight: 600;
}

.th-by {
    font-weight: 400;
    color: #94a3b8;
}

.th-meta {
    grid-area: meta;
    color: #64748b;
    font-size: 0.74rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 479px) {
    .th-meta { text-align: left; white-space: normal; }
}

.th-event--start .th-dot,
.th-event--resume .th-dot,
.th-event--continue .th-dot { background: #10b981; }
.th-event--pause .th-dot { background: #f59e0b; }
.th-event--save .th-dot { background: #3b82f6; }
.th-event--adjust .th-dot,
.th-event--hours .th-dot { background: #8b5cf6; }

.th-event--adjust .th-label,
.th-event--hours .th-label { color: #6d28d9; }

.th-event--live .th-dot {
    background: #10b981;
    animation: th-pulse 2s infinite;
}

.th-event--live .th-time,
.th-event--live .th-label { color: #047857; }

.th-gap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    color: #b45309;
    padding: 0.1rem 0 0.1rem 0;
}

.th-gap-line {
    width: 12px;
    height: 18px;
    flex: none;
    background: repeating-linear-gradient(to bottom, #fbbf24 0 3px, transparent 3px 6px) center / 2px 100% no-repeat;
}

.th-gap--open {
    font-weight: 600;
}

.th-foot {
    border-top: 1px solid #f1f5f9;
    padding: 0.4rem 0.8rem;
    font-size: 0.66rem;
    color: #94a3b8;
}

.th-loading,
.th-empty {
    padding: 0.85rem 0.8rem;
    font-size: 0.78rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.th-empty--error {
    color: #b91c1c;
}

.th-retry {
    border: none;
    background: none;
    color: #2563eb;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.th-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: th-spin 0.7s linear infinite;
}

@keyframes th-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .th-panel,
    .th-summary--running .th-status-dot,
    .th-event--live .th-dot,
    .th-spinner,
    .th-chevron {
        animation: none;
        transition: none;
    }
}

/* Placement on the pages that use it */

.timer-compact-controls .th-toggle {
    height: 2rem;
    padding: 0 0.7rem;
}

.timer-compact-spacer {
    flex: 1;
}

.project-entries > .th-wrap {
    padding: 0 20px 14px;
    border-bottom: 1px solid #f1f5f9;
}

.project-entries > .th-wrap .th-panel {
    margin-top: 0;
    max-width: 560px;
}

.entry-item .th-toggle--icon {
    margin-left: 12px;
}

/* Mobile entry cards stack full-width buttons; match them. */
.mobile-entry-card .th-toggle {
    width: 100%;
    justify-content: center;
    min-height: 2.75rem;
    margin-top: 0.5rem;
    border-radius: 10px;
    font-size: 0.85rem;
}

.org-timer-item .th-toggle--icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
}

.org-timer-item .th-panel {
    margin-top: 6px;
}

.actions-cell .th-toggle {
    margin-top: 0.4rem;
}

.th-stale {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.8rem;
    font-size: 0.72rem;
    color: #92400e;
    background: #fffbeb;
    border-bottom: 1px solid #fef3c7;
}
