/* ===================================================================
   TRIPS CSS - Tracking v2.0
   Estilos para la vista de viajes con mapa, timeline y pozos.
   =================================================================== */

/* =============== LAYOUT SPLIT =============== */
.trips-app-content {
    display: flex !important;
    padding: 0 !important;
    overflow: hidden !important;
    height: 100%;
}

/* ---- Panel izquierdo: Info ---- */
.trips-info-panel {
    width: 50%;
    min-width: 360px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
    background: var(--bg-primary);
}

/* ---- Stats grid ---- */
.trips-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    padding: 0.75rem;
    flex-shrink: 0;
}

.trips-stats .stat-card {
    padding: 0.5rem 0.6rem;
}

.trips-stats .stat-label {
    font-size: 10px;
}

.trips-stats .stat-value {
    font-size: var(--font-size-base);
}

/* ---- Toolbar ---- */
.trips-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.trips-toolbar .form-input {
    max-width: 140px;
    height: 30px;
    font-size: var(--font-size-xs);
    padding: 0 0.5rem;
}

.trips-toolbar .form-select {
    max-width: 180px;
    height: 30px;
    font-size: var(--font-size-xs);
}

/* ---- Lista scroll ---- */
.trips-list-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

/* ---- Resize handle ---- */
.trips-resize-handle {
    width: 5px;
    cursor: col-resize;
    background: var(--border-color);
    flex-shrink: 0;
    transition: background 0.15s;
}
.trips-resize-handle:hover,
.trips-resize-handle.active {
    background: var(--green-primary);
}

/* ---- Panel derecho: Mapa ---- */
.trips-map-panel {
    flex: 1;
    position: relative;
    min-width: 300px;
}

.trips-map {
    width: 100%;
    height: 100%;
}

/* ---- Leyenda del mapa ---- */
.trips-map-legend {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.4rem 0.6rem;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    z-index: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* =============== SECTION HEADERS =============== */
.trips-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.25rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

.trips-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.trips-section-count {
    font-size: 10px;
    font-weight: 600;
    background: var(--border-color);
    color: var(--text-secondary);
    padding: 1px 6px;
    border-radius: 8px;
}

/* =============== TRIP CARD =============== */
.trip-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: all 0.15s;
}

.trip-card:hover {
    background: var(--hover-color);
    border-color: var(--green-primary);
}

.trip-card-selected {
    background: var(--green-bg-soft);
    border-color: var(--green-primary);
    border-left: 3px solid var(--green-primary);
}

.trip-card-terminal {
    opacity: 0.7;
}

/* ---- Scheduled card ---- */
.sched-card {
    border-left: 3px solid #0ea5e9;
}

.sched-card:hover {
    border-color: #0ea5e9;
}

.sched-card.trip-card-selected {
    border-color: #0ea5e9;
    border-left-color: #0ea5e9;
    background: rgba(14,165,233,0.06);
}

.sched-status-badge {
    background: rgba(14,165,233,0.12) !important;
    color: #0ea5e9 !important;
}

.trip-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.trip-plate {
    font-weight: 700;
    font-family: 'Courier New', monospace;
    font-size: var(--font-size-sm);
    letter-spacing: 0.04em;
    color: var(--text-primary);
}

.trip-status-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.trip-card-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    min-width: 0;
}

.trip-operation,
.trip-route,
.trip-operator {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}

.trip-operator {
    font-style: italic;
}

.trip-route {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    max-width: 220px;
}

.trip-route-kind {
    flex-shrink: 0;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(0,166,81,0.10);
    color: var(--green-primary);
}

.trip-route-wells .trip-route-kind {
    background: rgba(139,92,246,0.12);
    color: #7c3aed;
}

.trip-route-hours .trip-route-kind {
    background: rgba(59,130,246,0.12);
    color: #2563eb;
}

.trip-route-summary,
.trip-route-detail {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trip-route-summary {
    min-width: 0;
}

.trip-route-detail {
    margin: -0.15rem 0 0.35rem;
    font-size: 11px;
    color: var(--text-secondary);
}

.trip-card-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
}

/* ---- Badges ---- */
.trip-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.badge-tarifa   { background: rgba(0,166,81,0.1); color: var(--green-primary); }
.badge-horas    { background: rgba(59,130,246,0.1); color: #3b82f6; }
.badge-pozos    { background: rgba(139,92,246,0.12); color: #7c3aed; }
.badge-time     { background: rgba(148,163,184,0.1); color: var(--text-secondary); }
.badge-shift    { background: rgba(99,102,241,0.12); color: #6366f1; font-weight: 600; }

.badge-distance {
    background: rgba(245,158,11,0.12);
    color: #d97706;
    font-weight: 600;
}

.badge-distance-enturne {
    background: rgba(245,158,11,0.08);
    color: #b45309;
    font-weight: 600;
}

.badge-order {
    background: rgba(148,163,184,0.1);
    color: var(--text-secondary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.badge-seq {
    background: rgba(139,92,246,0.12);
    color: #7c3aed;
    font-weight: 600;
}

/* ---- GPS status ---- */
.gps-status {
    font-size: 10px;
    font-weight: 500;
    padding: 1px 5px;
    border-radius: 4px;
}
.gps-moving { background: rgba(0,166,81,0.12); color: var(--green-primary); }
.gps-idle   { background: rgba(59,130,246,0.1); color: #3b82f6; }
.gps-off    { background: rgba(148,163,184,0.1); color: var(--text-secondary); }

/* ---- Well progress en card ---- */
.trip-well-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.3rem;
}

.well-label {
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.well-bar {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.well-bar-fill {
    height: 100%;
    background: #8b5cf6;
    border-radius: 2px;
    transition: width 0.3s;
}

/* =============== DETAIL PANEL =============== */
.trip-detail-panel {
    display: none;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    max-height: 45%;
    overflow-y: auto;
    flex-shrink: 0;
}

.trip-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.trip-detail-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.trip-detail-plate {
    font-weight: 700;
    font-family: 'Courier New', monospace;
    font-size: var(--font-size-sm);
}

.trip-detail-status {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: var(--border-radius);
    transition: background 0.15s;
}
.btn-icon:hover {
    background: var(--hover-color);
    color: var(--text-primary);
}

.trip-detail-body {
    padding: 0.5rem 0.75rem;
}

.detail-section {
    margin-bottom: 0.75rem;
}

.detail-section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
    font-size: var(--font-size-xs);
    border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-secondary);
    min-width: 90px;
}

.detail-shift {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 0.5rem;
    font-size: var(--font-size-xs);
}

.shift-remaining {
    font-weight: 600;
    color: #6366f1;
}

.text-danger {
    color: #ef4444;
    font-weight: 600;
}

.text-muted {
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
}

/* =============== TIMELINE =============== */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    padding-left: 12px;
}

.timeline-step {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.timeline-step:last-child {
    padding-bottom: 0;
}

/* Línea vertical conectora */
.timeline-step::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 12px;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-step:last-child::before {
    display: none;
}

.timeline-done::before {
    background: var(--green-primary);
}

.timeline-current::before {
    background: var(--green-primary);
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 3px;
    background: var(--border-color);
    border: 2px solid var(--border-color);
    z-index: 1;
}

.timeline-done .timeline-dot {
    background: var(--green-primary);
    border-color: var(--green-primary);
}

.timeline-current .timeline-dot {
    background: #fff;
    border-color: var(--green-primary);
    box-shadow: 0 0 0 3px rgba(0,166,81,0.25);
}

.timeline-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 14px;
}

.timeline-label {
    font-size: var(--font-size-xs);
    color: var(--text-primary);
}

.timeline-pending .timeline-label {
    color: var(--text-secondary);
}

.timeline-time {
    font-size: 10px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

/* =============== WELL LIST (DETAIL) =============== */
.well-progress-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.well-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6, #22c55e);
    border-radius: 3px;
    transition: width 0.3s;
}

.well-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.well-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.4rem;
    border-radius: var(--border-radius);
    font-size: var(--font-size-xs);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.well-item.well-visited {
    border-color: rgba(34,197,94,0.3);
    background: rgba(34,197,94,0.05);
}

.well-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.well-name {
    flex: 1;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.well-gal {
    font-size: 10px;
    color: var(--text-secondary);
}

.well-time {
    font-size: 10px;
    color: var(--green-primary);
    font-family: 'Courier New', monospace;
}

/* =============== EMPTY / LOADING =============== */
.trips-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-secondary);
}

.trips-empty h3 {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    color: var(--text-primary);
}

.trips-empty p {
    font-size: var(--font-size-xs);
}

.trips-loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* =============== RESPONSIVE =============== */
@media (max-width: 1024px) {
    .trips-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .trips-app-content {
        flex-direction: column !important;
    }

    .trips-info-panel {
        width: 100% !important;
        min-width: 100%;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .trips-resize-handle {
        display: none;
    }

    .trips-map-panel {
        min-height: 300px;
    }

    .trips-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}
