/* ==========================================================================
   RaceEngineer Dashboard Styles
   Component-specific styles for the Scale Dashboard page
   ========================================================================== */

/* Weight Input Components */
.weight-input {
    font-size: 1.8rem;
    font-weight: 800;
    text-align: center;
    color: var(--text-dark);
    border: 2px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    background: #f8fafc;
    height: 70px;
    z-index: 2;
    transition: all 0.2s;
}

.weight-input:focus {
    background: white;
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Hide number input spinners */
.weight-input::-webkit-outer-spin-button,
.weight-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.weight-input[type=number] {
    -moz-appearance: textfield;
}

.psi-input::-webkit-outer-spin-button,
.psi-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.psi-input[type=number] {
    -moz-appearance: textfield;
}

.sub-input-group {
    display: flex;
    box-shadow: 0 2px 4px -1px rgba(0,0,0,0.06);
}

.turn-input, .psi-input {
    width: 50%;
    border: 2px solid var(--border-color);
    border-top: none;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 4px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    color: var(--text-dark);
    background: white;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.turn-input {
    border-radius: 0 0 0 12px;
    color: #f97316;
    border-right: 1px solid var(--border-color);
}

.psi-input {
    border-radius: 0 0 12px 0;
    color: var(--accent);
    border-left: 1px solid var(--border-color);
}

.psi-input::placeholder {
    color: var(--accent);
    opacity: 0.7;
}

/* Metric Cards */
.metric-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.06);
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-dark);
}

/* Prediction Box */
.pred-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}

.pred-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--primary);
}

/* ==========================================================================
   Weight Delta Indicators
   ========================================================================== */

.weight-input-wrap {
    position: relative;
}

.weight-input-wrap .weight-input {
    padding-right: 50px;
}

.weight-delta {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    z-index: 3;
    white-space: nowrap;
}

.metric-delta {
    font-size: 0.7rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    margin-top: 2px;
}

.delta-pos { color: #16a34a; }
.delta-neg { color: #dc2626; }
.delta-neutral { color: #64748b; }

/* ==========================================================================
   Visual Weight Distribution Diagram
   ========================================================================== */

.weight-diagram-container {
    min-height: 160px;
    max-height: 280px;
}

.weight-diagram {
    width: 100%;
    max-width: 220px;
    aspect-ratio: 1 / 1.1;
    position: relative;
}

.car-outline {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px solid #e2e8f0;
    border-radius: 40% 40% 35% 35% / 15% 15% 20% 20%;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.04);
}

.corner-weight {
    position: absolute;
    width: 52px;
    height: 52px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid #e2e8f0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    z-index: 2;
}

.corner-weight.lf { top: 8%; left: 5%; }
.corner-weight.rf { top: 8%; right: 5%; }
.corner-weight.lr { bottom: 8%; left: 5%; }
.corner-weight.rr { bottom: 8%; right: 5%; }

.corner-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    line-height: 1;
}

.corner-value {
    font-size: 0.95rem;
    font-weight: 800;
    color: #1e293b;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.2;
}

.corner-pct {
    font-size: 0.6rem;
    font-weight: 600;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
}

.corner-weight.corner-good {
    border-color: #22c55e;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.corner-weight.corner-warn {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.corner-weight.corner-alert {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.center-cross-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 3;
}

.cross-value {
    font-size: 0.9rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.2;
}

.cross-label {
    font-size: 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.cross-value.cross-good { color: #16a34a; }
.cross-value.cross-warn { color: #d97706; }
.cross-value.cross-alert { color: #dc2626; }

.diagonal-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.diag-line {
    stroke: #cbd5e1;
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
    opacity: 0.6;
}

.diag-line.cross-diag {
    stroke: #3b82f6;
}

.diag-line.diag-heavy {
    stroke-width: 2.5;
    opacity: 0.8;
}

.diag-line.cross-diag.diag-heavy {
    stroke: #2563eb;
    stroke-width: 2.5;
}

.axle-label {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
    background: rgba(255,255,255,0.8);
    padding: 2px 6px;
    border-radius: 4px;
}

.front-label { top: 4px; }
.rear-label { bottom: 4px; }

.handling-description {
    min-height: 18px;
}

/* Responsive adjustments for weight diagram */
@media (max-width: 768px) {
    .weight-diagram {
        max-width: 180px;
    }
    
    .corner-weight {
        width: 44px;
        height: 44px;
    }
    
    .corner-value {
        font-size: 0.8rem;
    }
    
    .corner-label, .corner-pct {
        font-size: 0.55rem;
    }
    
    .center-cross-indicator {
        width: 50px;
        height: 50px;
    }
    
    .cross-value {
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    .weight-diagram-container {
        min-height: 140px;
    }
    
    .weight-diagram {
        max-width: 160px;
    }
    
    .corner-weight {
        width: 40px;
        height: 40px;
    }
    
    .corner-value {
        font-size: 0.75rem;
    }
    
    .corner-label, .corner-pct {
        font-size: 0.5rem;
    }
    
    .center-cross-indicator {
        width: 46px;
        height: 46px;
    }
    
    .cross-value {
        font-size: 0.7rem;
    }
    
    .axle-label {
        font-size: 0.5rem;
    }
}

/* History Table Overrides */
.table-history th {
    position: sticky;
    top: 0;
    z-index: 5;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: #f9fafb;
    border-bottom: 1px solid var(--border-color);
}

.table-history td {
    font-size: 0.9rem;
    vertical-align: middle;
}

/* Row Styles */
.baseline-row {
    background-color: #ecfdf5 !important;
}

.ghost-data {
    color: var(--text-muted) !important;
}

.ghost-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #f59e0b;
}

/* FAB Compare Button */
.fab-compare {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1050;
    border-radius: 50px;
    padding: 12px 28px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    background: var(--text-dark);
    color: #fff;
    border: none;
    transition: all 0.2s;
}

.fab-compare:hover {
    transform: translateY(-2px);
}

/* Labels */
.label-small {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}

/* Typography Utilities */
.mono-font {
    font-family: 'JetBrains Mono', monospace;
}

/* Diff Colors */
.diff-pos {
    color: #16a34a;
    font-weight: 700;
}

.diff-neg {
    color: #ef4444;
    font-weight: 700;
}

/* Editing Mode */
.editing-mode .app-card {
    border-color: rgba(37, 99, 235, 0.5);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn-update {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Dashboard Header Compact Mode */
body.dashboard-compact-header .glass-nav {
    margin-bottom: 0.75rem !important;
}

/* Chart Cards */
.cog-card {
    height: 340px;
}

.cog-card canvas {
    width: 100% !important;
    height: 100% !important;
}

.cross-card {
    height: 240px;
}

.cog-chart-wrap {
    flex: 1;
    height: 280px;
}

/* ==========================================================================
   Scale Grid Layout
   ========================================================================== */

.scale-grid {
    display: grid;
    grid-template-columns: 1fr 180px 1fr;
    gap: 12px;
    align-items: end;
}

.scale-cell {
    min-width: 0;
}

.between-metric {
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 90px;
    align-self: center;
}

.center-metric {
    padding: 12px;
    align-self: center;
}

.center-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.center-divider {
    height: 1px;
    width: 100%;
    background: var(--border-color);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* Tablet breakpoint */
@media (max-width: 768px) {
    .scale-grid {
        grid-template-columns: 1fr 140px 1fr;
        gap: 10px;
    }
    .weight-input {
        font-size: 1.5rem;
        height: 60px;
    }
    .metric-value {
        font-size: 1.1rem;
    }
    .between-metric {
        padding: 8px;
        min-height: 70px;
    }
    .center-metric {
        padding: 10px;
    }
}

/* Mobile breakpoint */
@media (max-width: 576px) {
    .app-card {
        padding: 16px;
    }
    .scale-grid {
        grid-template-columns: 1fr 100px 1fr;
        gap: 6px;
    }
    .scale-cell {
        min-width: 0;
    }
    .weight-input {
        font-size: 1.3rem;
        height: 54px;
        border-radius: 8px 8px 0 0;
    }
    .turn-input, .psi-input {
        font-size: 0.7rem;
        padding: 5px 2px;
        border-radius: 0 0 0 8px;
    }
    .psi-input {
        border-radius: 0 0 8px 0;
    }
    .label-small {
        font-size: 0.65rem;
        margin-bottom: 4px;
    }
    .metric-card {
        padding: 6px;
        border-radius: 8px;
    }
    .metric-value {
        font-size: 0.95rem;
    }
    .between-metric {
        padding: 4px;
        min-height: 54px;
    }
    .center-metric {
        padding: 6px;
    }
    .center-stack {
        gap: 6px;
    }
    .center-metric .h3 {
        font-size: 1.3rem !important;
    }
    .center-metric .h4 {
        font-size: 1.1rem !important;
    }
    .center-metric .small {
        font-size: 0.7rem !important;
    }
    
    /* Mobile-friendly Scale Drop header */
    .scale-drop-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    .scale-drop-header h5 {
        font-size: 1.1rem;
    }
    .scale-drop-header .form-check {
        align-self: flex-end;
    }
    .scale-drop-header .form-check-label {
        font-size: 0.6rem !important;
    }
}

/* Extra small phones */
@media (max-width: 400px) {
    .app-card {
        padding: 12px;
    }
    .scale-grid {
        grid-template-columns: 1fr 80px 1fr;
        gap: 4px;
    }
    .weight-input {
        font-size: 1.1rem;
        height: 48px;
    }
    .turn-input, .psi-input {
        font-size: 0.6rem;
        padding: 4px 1px;
    }
    .label-small {
        font-size: 0.6rem;
        letter-spacing: 0.04em;
    }
    .metric-value {
        font-size: 0.85rem;
    }
    .between-metric {
        padding: 3px;
        min-height: 48px;
    }
    .center-metric {
        padding: 4px;
    }
    .center-metric .h3 {
        font-size: 1.1rem !important;
    }
    .center-metric .h4 {
        font-size: 0.95rem !important;
    }
    .center-metric .small {
        font-size: 0.65rem !important;
    }
}

/* ==========================================================================
   Dashboard Topbar Controls
   ========================================================================== */

.dashboard-topbar-controls .btn,
.dashboard-topbar-controls .form-select,
.dashboard-topbar-controls .input-group-sm > .form-control,
.dashboard-topbar-controls .input-group-sm > .input-group-text {
    height: 31px; /* Bootstrap "sm" control height */
}

.dashboard-topbar-controls .btn {
    display: inline-flex;
    align-items: center;
}

/* ==========================================================================
   Ko-fi Widget Dashboard Overrides
   ========================================================================== */

#kofi-widget-overlay,
.floatingchat-container {
    bottom: 24px;
}

body.kofi-above-footer #kofi-widget-overlay,
body.kofi-above-footer .floatingchat-container {
    bottom: 96px !important;
}

/* ==========================================================================
   Vue Cloak
   ========================================================================== */

[v-cloak] {
    display: none !important;
}
