/* ═══════════════════════════════════════════
   TrainControl — Locomotive Control Card
   Matches native iOS/macOS app design
   ═══════════════════════════════════════════ */

/* ── Card header ── */
.loco-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--gap-md) var(--gap-lg);
}

.loco-card-info {
    display: flex;
    align-items: center;
    gap: var(--gap-md);
}

.loco-card-thumb {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #5b82c9, #3a5a9e);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}
.loco-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.loco-card-thumb .thumb-emoji {
    font-size: 1.6rem;
}

.loco-card-meta h3 {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
}
.loco-card-meta .loco-address {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.loco-card-actions {
    display: flex;
    gap: var(--gap-sm);
}

.btn-card-action {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.06);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all var(--duration-fast) ease;
}
.btn-card-action:hover {
    background: rgba(0,0,0,0.10);
}
.btn-card-settings { font-size: 1.3rem; }
.btn-card-close {
    font-size: 1rem;
    color: var(--text-tertiary);
}

/* ── Divider ── */
.loco-card-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0 var(--gap-lg);
}

/* ── Card body ── */
.loco-card-body {
    display: flex;
    gap: var(--gap-md);
    padding: var(--gap-md) var(--gap-lg);
    flex: 1;
}

/* ── Section labels ── */
.section-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
    margin-bottom: var(--gap-xs);
    display: block;
}

/* ═════════════════════════════════════
   SPEED SECTION (vertical track slider)
   ═════════════════════════════════════ */

.speed-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gap-xs);
    min-width: 48px;
}

.speed-slider-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: stretch;
    min-height: 200px;
}

.speed-track {
    width: 36px;
    background: rgba(0,0,0,0.06);
    border-radius: 18px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.speed-fill {
    width: 100%;
    background: var(--tc-blue);
    opacity: 0.3;
    border-radius: 18px;
    transition: height 100ms ease;
    min-height: 0;
}

/* Invisible range input overlayed on the track */
.speed-input-hidden {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    writing-mode: vertical-lr;
    direction: rtl;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    opacity: 0;
    margin: 0;
}
.speed-input-hidden::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 36px;
    height: 36px;
}

.speed-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--tc-blue);
}

/* ═════════════════════════════════════
   FUNCTIONS GRID (3×3 capsules)
   ═════════════════════════════════════ */

.right-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--gap-sm);
}

.fn-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap-sm);
}

.fn-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 56px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all var(--duration-fast) var(--ease-out);
    padding: 4px 8px;
}
.fn-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}
.fn-btn:active {
    transform: scale(0.95);
}
.fn-btn.active {
    background: var(--tc-blue);
    color: white;
    box-shadow: 0 2px 10px rgba(67,89,144,0.3);
}
.fn-btn-icon {
    font-size: 1.1rem;
    line-height: 1;
}
.fn-btn-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.fn-btn.active .fn-btn-label {
    color: rgba(255,255,255,0.85);
}

/* ═════════════════════════════════════
   DIRECTION BUTTON
   ═════════════════════════════════════ */

.dir-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 1rem;
    font-family: var(--font-sans);
    color: white;
    cursor: pointer;
    transition: background var(--duration-med) ease, transform var(--duration-fast) var(--ease-spring);
    text-align: center;
}
.dir-btn[data-dir="forward"] {
    background: var(--tc-green);
}
.dir-btn[data-dir="reverse"] {
    background: var(--tc-red);
}
.dir-btn:hover {
    filter: brightness(1.05);
}
.dir-btn:active {
    transform: scale(0.98);
}

/* ═════════════════════════════════════
   STOP BUTTON (square-ish, red, bottom-left)
   ═════════════════════════════════════ */

.stop-btn {
    position: absolute;
    bottom: var(--gap-md);
    left: var(--gap-lg);
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--tc-red);
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(209,69,80,0.35);
    transition: all var(--duration-fast) var(--ease-spring);
    z-index: 2;
}
.stop-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 18px rgba(209,69,80,0.45);
}
.stop-btn:active {
    transform: scale(0.94);
}

/* ── Filled slot needs position relative for stop btn ── */
.grid-slot.filled {
    position: relative;
    padding-bottom: 70px; /* room for stop button */
}

/* ═════════════════════════════════════
   LOCO SETTINGS MODAL extras
   ═════════════════════════════════════ */

.loco-photo-upload {
    display: flex;
    align-items: center;
    gap: var(--gap-md);
}

.loco-photo-preview {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #5b82c9, #3a5a9e);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.btn-upload {
    cursor: pointer;
    text-align: center;
    font-size: 0.82rem;
}

.btn-remove-photo {
    font-size: 0.78rem;
    color: var(--tc-red) !important;
    border-color: rgba(209,69,80,0.3) !important;
}

.modal-danger-zone {
    padding-top: var(--gap-md);
    border-top: 1px solid var(--border-light);
    margin-top: var(--gap-sm);
}

.btn-danger {
    width: 100%;
    padding: 12px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: var(--font-sans);
    color: var(--tc-red);
    background: rgba(209,69,80,0.08);
    border: 1px solid rgba(209,69,80,0.2);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-fast) ease;
}
.btn-danger:hover {
    background: rgba(209,69,80,0.15);
}
