/* ==========================================================================
   forward-manager.css — Route Forward Manager feature styles
   Part of the v2.0 CSS modularization.

   Contents: all .rfm-* classes (tabs, stats, search bar, inputs, card grid,
   table, form grid, buttons, textarea, code block, guide table, stop badge),
   plus the RFM headline "Expiring Soon" card variants (clear/warn/urgent)
   and the expiring-row layout.
   ========================================================================== */

/* ==========================================================================
   Route Forward Manager Tool
   ========================================================================== */
.rfm-hidden { display: none !important; }
.rfm-tabs { display: flex; gap: 2px; margin-bottom: 1rem; background: var(--light-card-bg); border: 1px solid var(--border-light); border-radius: 0.5rem; overflow: hidden; }
.theme-dark .rfm-tabs { background: var(--dark-card-bg); border-color: var(--border-dark); }
.rfm-tab { flex: 1; padding: 0.6rem; background: transparent; border: none; color: var(--light-text); font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: background 0.15s; }
.theme-dark .rfm-tab { color: var(--dark-text); }
.rfm-tab.active { background: var(--primary-blue); color: #fff; }
.rfm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 1rem; }
.rfm-stat { background: var(--light-card-bg); border: 1px solid var(--border-light); border-radius: 0.5rem; padding: 0.75rem; text-align: center; }
.theme-dark .rfm-stat { background: var(--dark-card-bg); border-color: var(--border-dark); }
.rfm-stat-label { display: block; font-size: 0.7rem; color: #666; }
.theme-dark .rfm-stat-label { color: #999; }
.rfm-stat-value { display: block; font-size: 1.5rem; font-weight: 700; }
.rfm-green { color: #22c55e; }
.rfm-yellow { color: #f59e0b; }
.rfm-red { color: #ef4444; }
.rfm-dim { color: #999; font-weight: 400; font-size: 0.8em; }
.rfm-small { font-size: 0.75rem; }
.rfm-mono { font-family: 'SF Mono', 'Consolas', monospace; font-size: 0.7rem; }
.rfm-search-bar { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.rfm-input { background: var(--light-card-bg); border: 1px solid var(--border-light); border-radius: 0.4rem; padding: 0.5rem 0.75rem; color: var(--light-text); font-size: 0.85rem; width: 100%; }
.theme-dark .rfm-input { background: var(--dark-bg); border-color: var(--border-dark); color: var(--dark-text); }
.rfm-select { width: auto; min-width: 120px; flex: 0; }
.rfm-search-bar .rfm-input:first-child { flex: 1; min-width: 140px; }
.rfm-card { background: var(--light-card-bg); border: 1px solid var(--border-light); border-radius: 0.5rem; padding: 1rem; margin-bottom: 0.75rem; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.theme-dark .rfm-card { background: var(--dark-card-bg); border-color: var(--border-dark); }
.rfm-card-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }
.rfm-table-wrap { overflow-x: auto; }
.rfm-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.rfm-table th { text-align: left; font-weight: 500; padding: 0.4rem 0.5rem 0.4rem 0; border-bottom: 1px solid var(--border-light); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.3px; color: #888; }
.theme-dark .rfm-table th { border-color: var(--border-dark); color: #888; }
.rfm-table td { padding: 0.5rem 0.5rem 0.5rem 0; border-bottom: 1px solid rgba(0,0,0,0.05); vertical-align: top; }
.theme-dark .rfm-table td { border-bottom-color: rgba(255,255,255,0.05); }
.rfm-name { font-weight: 500; }
.rfm-inactive td { opacity: 0.4; }
.rfm-inactive .rfm-name { text-decoration: line-through; }
.rfm-edit-btn { background: var(--primary-blue); color: #fff; border: none; border-radius: 0.3rem; padding: 0.2rem 0.6rem; font-size: 0.7rem; cursor: pointer; }
.rfm-edit-btn:hover { background: rgba(13,110,253,0.8); }
.rfm-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.rfm-field label { display: block; font-size: 0.7rem; color: #888; margin-bottom: 0.2rem; }
.rfm-form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.rfm-btn { font-size: 0.85rem !important; padding: 0.5rem 1rem !important; }
.rfm-btn-secondary { background: #6b7280; color: #fff; border: 1px solid #6b7280; }
.rfm-btn-secondary:hover { background: #4b5563; }
.rfm-btn-warn { background: #f59e0b; color: #000; border: 1px solid #f59e0b; }
.rfm-btn-warn:hover { background: #d97706; }
.rfm-btn-danger { background: #ef4444; color: #fff; border: 1px solid #ef4444; }
.rfm-btn-danger:hover { background: #dc2626; }
.rfm-textarea { width: 100%; background: var(--light-card-bg); border: 1px solid var(--border-light); border-radius: 0.4rem; padding: 0.5rem; color: var(--light-text); font-size: 0.8rem; font-family: monospace; resize: vertical; }
.theme-dark .rfm-textarea { background: var(--dark-bg); border-color: var(--border-dark); color: var(--dark-text); }
.rfm-code-block { background: var(--light-bg); border: 1px solid var(--border-light); border-radius: 0.5rem; padding: 0.75rem; font-family: 'SF Mono','Consolas',monospace; font-size: 0.7rem; line-height: 1.5; white-space: pre-wrap; max-height: 300px; overflow-y: auto; color: #555; }
.theme-dark .rfm-code-block { background: var(--dark-bg); border-color: var(--border-dark); color: #aaa; }
.rfm-ol { padding-left: 1.5rem; line-height: 2; }
.rfm-ul { padding-left: 1.5rem; line-height: 2; list-style: disc; }
.rfm-guide-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.rfm-guide-table th { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 2px solid var(--border-light); font-size: 0.75rem; }
.rfm-guide-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border-light); }
.theme-dark .rfm-guide-table th, .theme-dark .rfm-guide-table td { border-color: var(--border-dark); }
@media (max-width: 640px) {
    .rfm-form-grid { grid-template-columns: 1fr; }
    .rfm-hide-mobile { display: none; }
    .rfm-table { font-size: 0.75rem; }
    .rfm-tab { font-size: 0.7rem; padding: 0.5rem 0.25rem; }
}
@media print {
    .rfm-tabs, .rfm-search-bar, .rfm-form-actions, .rfm-edit-btn, .rfm-btn { display: none !important; }
    .rfm-card { break-inside: avoid; }
}
.rfm-stop-badge { background: var(--light-card-bg); border: 1px solid var(--border-light); border-radius: 0.5rem; padding: 4px 8px; text-align: center; min-width: 44px; }
.theme-dark .rfm-stop-badge { background: var(--dark-bg); border-color: var(--border-dark); }
.rfm-stop-badge:hover { border-color: var(--primary-blue); }

/* ==========================================================================
   Route Forward Manager — Headline (Expiring Soon) card
   The dashboard's primary assurance signal: glance once, know if anything
   needs attention. Borders + state strip use USPS palette (blue/red) with
   amber as the only non-USPS warning color, full light/dark support.
   ========================================================================== */
.rfm-headline-card {
    border-width: 1px;
    border-style: solid;
    border-left-width: 6px;
    margin-bottom: 1rem;
    transition: border-color 0.2s, background-color 0.2s;
}
.rfm-headline-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}
.rfm-headline-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.15rem 0;
    line-height: 1.2;
}
.rfm-headline-sub {
    font-size: 0.78rem;
    margin: 0;
    opacity: 0.85;
    font-weight: 500;
}
.rfm-headline-clear { border-left-color: #22c55e; }
.rfm-headline-clear .rfm-headline-title { color: #16a34a; }
.theme-dark .rfm-headline-clear .rfm-headline-title { color: #4ade80; }

.rfm-headline-warn { border-left-color: #f59e0b; }
.rfm-headline-warn .rfm-headline-title { color: #b45309; }
.theme-dark .rfm-headline-warn .rfm-headline-title { color: #fbbf24; }

.rfm-headline-urgent {
    border-left-color: #dc2626;
    background: rgba(220, 38, 38, 0.04);
}
.theme-dark .rfm-headline-urgent { background: rgba(220, 38, 38, 0.10); }
.rfm-headline-urgent .rfm-headline-title { color: #b91c1c; }
.theme-dark .rfm-headline-urgent .rfm-headline-title { color: #f87171; }

.rfm-expiring-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}
.rfm-expiring-row:last-child { border-bottom: none; }
.theme-dark .rfm-expiring-row { border-bottom-color: var(--border-dark); }
.rfm-expiring-info { min-width: 0; flex: 1; }

/* ==========================================================================
   Phase A — History panel inside the edit form
   Collapsible <details> showing every event for the forward being edited.
   Newest first. Each row: action label + relative timestamp; updates also
   show a per-field diff list.
   ========================================================================== */
.rfm-history-details {
    margin-top: 1rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 0;
    background: var(--light-card-bg);
}
.theme-dark .rfm-history-details {
    background: var(--dark-card-bg);
    border-color: var(--border-dark);
}
.rfm-history-summary {
    cursor: pointer;
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-blue);
    user-select: none;
    list-style: none;
}
.theme-dark .rfm-history-summary { color: #6ea8fe; }
.rfm-history-summary::-webkit-details-marker { display: none; }
.rfm-history-summary::before {
    content: '▸ ';
    display: inline-block;
    transition: transform 0.15s ease;
    margin-right: 0.2rem;
}
.rfm-history-details[open] .rfm-history-summary::before {
    transform: rotate(90deg);
}
.rfm-history-count {
    font-weight: 400;
    opacity: 0.7;
    margin-left: 0.25rem;
}
.rfm-history-list {
    padding: 0 0.85rem 0.65rem 0.85rem;
    max-height: 360px;
    overflow-y: auto;
}
.rfm-history-row {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.78rem;
}
.rfm-history-row:last-child { border-bottom: none; }
.theme-dark .rfm-history-row { border-bottom-color: var(--border-dark); }
.rfm-history-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}
.rfm-history-action {
    font-weight: 600;
}
.rfm-history-when {
    font-size: 0.72rem;
    opacity: 0.7;
    white-space: nowrap;
    font-family: 'SF Mono', 'Consolas', monospace;
}
.rfm-history-fields {
    list-style: none;
    padding: 0;
    margin: 0.4rem 0 0 0;
    font-size: 0.74rem;
}
.rfm-history-fields li {
    padding: 0.15rem 0;
    color: var(--light-text);
    opacity: 0.85;
    word-break: break-word;
}
.theme-dark .rfm-history-fields li { color: var(--dark-text); }
.rfm-history-arrow {
    color: var(--primary-blue);
    margin: 0 0.2rem;
    font-weight: 700;
}
.theme-dark .rfm-history-arrow { color: #6ea8fe; }

/* ==========================================================================
   Stop renaming — inline edit on Forwards-tab group headers
   The pencil icon sits next to each stop's group title. Click → header
   transforms into an editable input + Save / Cancel buttons. The numeric
   route position (cbu_stop) never changes — only the display label.
   ========================================================================== */
.rfm-stop-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.rfm-stop-display-name {
    /* inherits the h3 styling, no extra rules needed */
}
.rfm-stop-num-suffix {
    font-weight: 400;
    font-size: 0.8em;
}
.rfm-stop-rename-btn,
.rfm-stop-save-btn,
.rfm-stop-cancel-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--primary-blue);
    padding: 0.2rem 0.5rem;
    border-radius: 0.35rem;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    opacity: 0.55;
}
.rfm-stop-rename-btn:hover,
.rfm-stop-save-btn:hover {
    opacity: 1;
    background: rgba(13, 110, 253, 0.1);
    border-color: rgba(13, 110, 253, 0.3);
}
.theme-dark .rfm-stop-rename-btn,
.theme-dark .rfm-stop-save-btn { color: #6ea8fe; }
.theme-dark .rfm-stop-rename-btn:hover,
.theme-dark .rfm-stop-save-btn:hover {
    background: rgba(110, 168, 254, 0.15);
    border-color: rgba(110, 168, 254, 0.4);
}
.rfm-stop-cancel-btn {
    color: #6b7280;
}
.rfm-stop-cancel-btn:hover {
    opacity: 1;
    background: rgba(107, 114, 128, 0.1);
    border-color: rgba(107, 114, 128, 0.3);
}
.theme-dark .rfm-stop-cancel-btn { color: #9ca3af; }
.theme-dark .rfm-stop-cancel-btn:hover { background: rgba(156, 163, 175, 0.12); }
.rfm-stop-rename-input {
    font-size: 1rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border: 2px solid var(--primary-blue);
    border-radius: 0.35rem;
    background: var(--light-card-bg);
    color: var(--light-text);
    min-width: 140px;
    flex: 1;
    max-width: 260px;
    font-family: inherit;
}
.theme-dark .rfm-stop-rename-input {
    background: var(--dark-bg);
    color: var(--dark-text);
    border-color: #6ea8fe;
}
.rfm-stop-rename-input:focus {
    outline: 2px solid rgba(13, 110, 253, 0.3);
    outline-offset: 2px;
}
