/* ══════════════════════════════════════════════
   ROUTES PAGE — routes.css
   Requires: base.css loaded before this file.
   ══════════════════════════════════════════════ */

/* ── LAYOUT ──────────────────────────────────── */
.routes-wrapper {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    align-items: start;
}

/* ── TOOLBAR ─────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 8px;
    padding: 0 12px;
    height: 38px;
    flex: 1;
    max-width: 300px;
    transition: border .2s, box-shadow .2s;
}

.search-box:focus-within {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .08);
}

.search-box i {
    font-size: 12px;
    color: #c0c0c0;
}

.search-box input {
    border: none;
    outline: none;
    font-size: 13px;
    width: 100%;
    background: transparent;
    color: #333;
    font-family: inherit;
}

.btn-add {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: .2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.btn-add:hover {
    background: var(--color-brand);
    /* was: #3e5272 */
    box-shadow: 0 4px 12px rgba(46, 58, 77, .2);
}

/* ── ROUTES CARD ─────────────────────────────── */
.routes-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .07);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .05);
}

.routes-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}

.routes-card-header h2 {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
}

.routes-card-header span {
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, .04);
    padding: 3px 10px;
    border-radius: 20px;
}

.routes-table-wrap {
    overflow-x: auto;
}

.routes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.routes-table thead th {
    text-align: left;
    padding: 10px 16px;
    font-size: 10.5px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: #fafafa;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    white-space: nowrap;
}

.routes-table tbody tr {
    border-bottom: 1px solid rgba(0, 0, 0, .04);
    transition: background .15s;
    cursor: pointer;
}

.routes-table tbody tr:last-child {
    border-bottom: none;
}

.routes-table tbody tr:hover {
    background: #fafafa;
}

.routes-table tbody tr.selected {
    background: rgba(249, 115, 22, .04);
    border-left: 3px solid var(--color-accent);
}

.routes-table td,
.routes-table th {
    padding: 14px 12px;
    white-space: nowrap;
}

.routes-table tbody td {
    color: #374151;
    vertical-align: middle;
}

/* Route display */
.route-display {
    display: flex;
    align-items: center;
    gap: 10px;
}

.route-point {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.route-point .label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #9ca3af;
}

.route-point .value {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-primary);
}

.route-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-accent);
    flex-shrink: 0;
    opacity: .7;
    height: 100%;
}

.route-arrow i {
    font-size: 12px;
    display: inline-block;
    transform: translateY(2px);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.badge.active {
    background: rgba(22, 163, 74, .08);
    color: #16a34a;
}

.badge.active::before {
    background: #16a34a;
}

.badge.inactive {
    background: rgba(239, 68, 68, .08);
    color: #ef4444;
}

.badge.inactive::before {
    background: #ef4444;
}

/* Stops pills */
.stops-pills {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
}

.stop-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #6b7280;
    background: rgba(0, 0, 0, .04);
    padding: 2px 8px;
    border-radius: 20px;
}

/* Row actions */
.row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12.5px;
    transition: background .15s, color .15s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, .06);
    color: var(--color-primary);
}

.icon-btn.edit {
    background: rgba(249, 115, 22, .08);
    color: var(--color-accent); 
}

.icon-btn.edit:hover {
    transform: translateY(-1px);
}

.icon-btn.delete {
    background: rgba(239, 68, 68, .08);
    color: #ef4444;
}
.icon-btn.delete:hover {
    transform: translateY(-1px);
}

.icon-btn.toggle{
    background: rgba(22, 163, 74, .08);
    color: #16a34a;
}

.icon-btn.toggle:hover {
    transform: translateY(-1px);
}

/* Empty state */
.empty-state {
    padding: 48px 20px;
    text-align: center;
    color: #d1d5db;
}

.empty-state i {
    font-size: 36px;
    margin-bottom: 10px;
    display: block;
}

.empty-state p {
    font-size: 13px;
    margin: 0;
}

.text-muted-sm {
    font-size: 12px;
    color: #9ca3af;
}

/* ── MAP CARD ─────────────────────────────────── */
.map-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .07);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .05);
    position: sticky;
    top: 80px;
    isolation: isolate;
}

.map-card-header {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    display: flex;
    align-items: center;
    gap: 10px;
}

.map-card-header i {
    font-size: 13px;
    color: var(--color-accent);
}

.map-card-header p {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--color-primary);
    flex: 1;
}

.map-card-header span {
    font-size: 11px;
    color: var(--text-muted);
    max-width: 140px;
    text-align: right;
    line-height: 1.3;
}

#route-map {
    height: 300px;
    width: 100%;
}

.map-empty {
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #d1d5db;
}

.map-empty i {
    font-size: 32px;
}

.map-empty p {
    font-size: 13px;
    margin: 0;
}

.map-route-info {
    padding: 14px 16px;
    border-top: 1px solid rgba(0, 0, 0, .06);
    display: none;
}

.map-route-info.visible {
    display: block;
}

.map-route-stops {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-stop {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stop-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid;
    flex-shrink: 0;
}

.stop-dot.origin {
    border-color: #16a34a;
    background: rgba(22, 163, 74, .15);
}

.stop-dot.dest {
    border-color: #ef4444;
    background: rgba(239, 68, 68, .15);
}

.stop-dot.via {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, .15);
}

.stop-connector {
    width: 2px;
    height: 14px;
    background: rgba(249, 115, 22, .3);
    margin-left: 4px;
}

.map-stop span {
    font-size: 12.5px;
    color: #374151;
    font-weight: 500;
}

.map-stop .stop-label {
    font-size: 9.5px;
    color: #9ca3af;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: .4px;
}

/* ── FARE INPUT ───────────────────────────────── */
.rinput {
    width: 100%;
    height: 38px;
    padding: 0 11px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, .1);
    background: var(--input-bg);
    font-size: 13px;
    font-family: inherit;
    color: #374151;
    outline: none;
    transition: border .18s, box-shadow .18s, background .18s;
}

.rinput::placeholder {
    color: #bbb;
}

.rinput:hover {
    border-color: rgba(0, 0, 0, .18);
    background: #fff;
}

.rinput:focus {
    border-color: var(--color-accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .08);
}

/* ── SEARCHABLE SELECT ────────────────────────── */
select.ss {
    display: none !important;
}

.ss-wrap {
    position: relative;
    width: 100%;
}

.ss-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 38px;
    padding: 0 11px;
    background: var(--input-bg);
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    font-family: inherit;
    transition: border .18s, box-shadow .18s, background .18s;
    text-align: left;
    gap: 8px;
}

.ss-btn:hover {
    border-color: rgba(0, 0, 0, .18);
    background: #fff;
}

.ss-btn.is-open {
    border-color: var(--color-accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .08);
}

.ss-btn.is-placeholder .ss-btn-txt {
    color: #aaa;
}

.ss-btn-txt {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.ss-btn-arr {
    font-size: 10px;
    color: #aaa;
    flex-shrink: 0;
    transition: transform .2s;
}

.ss-btn.is-open .ss-btn-arr {
    transform: rotate(180deg);
}

.ss-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .1);
    z-index: 9999;
    overflow: hidden;
    display: none;
}

.ss-panel.is-open {
    display: block;
}

.ss-search-wrap {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}

.ss-search-wrap i {
    font-size: 11px;
    color: #bbb;
}

.ss-search {
    border: none;
    outline: none;
    font-size: 12.5px;
    width: 100%;
    background: transparent;
    color: #333;
    font-family: inherit;
}

.ss-search::placeholder {
    color: #bbb;
}

.ss-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 200px;
    overflow-y: auto;
}

.ss-list::-webkit-scrollbar {
    width: 4px;
}

.ss-list::-webkit-scrollbar-track {
    background: transparent;
}

.ss-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .12);
    border-radius: 4px;
}

.ss-item {
    padding: 8px 12px;
    font-size: 12.5px;
    color: #374151;
    cursor: pointer;
    transition: background .12s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ss-item:hover {
    background: rgba(249, 115, 22, .06);
    color: var(--color-primary);
}

.ss-item.is-sel {
    background: rgba(249, 115, 22, .08);
    color: var(--color-accent);
    font-weight: 600;
}

.ss-item.is-sel::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 10px;
    margin-left: auto;
}

.ss-item.is-placeholder {
    color: #aaa;
    font-style: italic;
}

.ss-no-results {
    padding: 14px 12px;
    font-size: 12px;
    color: #aaa;
    text-align: center;
}

/* ── MODAL ────────────────────────────────────── */
.rmodal {
    border: 0 !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .18) !important;
    overflow: hidden;
}

.rmodal-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 20px 20px 0;
}

.rmodal-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: rgba(249, 115, 22, .09);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-accent);
    font-size: 14px;
}

.rmodal-icon.edit {
    background: rgba(46, 58, 77, .07);
    color: var(--color-primary);
}

.rmodal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0 0 2px;
    line-height: 1.2;
}

.rmodal-sub {
    font-size: 11.5px;
    color: #9ca3af;
    margin: 0;
}

.rmodal-body {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 60vh;
    overflow-y: auto;
}

.rmodal-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(0, 0, 0, .06);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.modal-dialog-scrollable .modal-content {
    max-height: 90vh;
}

.rfield {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rfield-label {
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rfield-label i {
    color: #c0c0c0;
    font-size: 10px;
}

.rfield-opt {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-style: italic;
    color: #bbb;
    font-size: 10.5px;
}

.stops-counter {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    color: #bbb;
    background: rgba(0, 0, 0, .04);
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0;
    text-transform: none;
    font-style: normal;
}

.stops-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-height: 0;
}

.dynamic-stop-row {
    display: flex;
    align-items: center;
    gap: 8px;
    animation: stopRowIn .18s ease;
}

@keyframes stopRowIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dynamic-stop-row .stop-num {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    background: rgba(249, 115, 22, .09);
    color: var(--color-accent);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dynamic-stop-row .ss-wrap {
    flex: 1;
    min-width: 0;
}

.btn-remove-stop {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(239, 68, 68, .2);
    background: rgba(239, 68, 68, .05);
    color: #ef4444;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    transition: background .15s, border-color .15s, transform .1s;
}

.btn-remove-stop:hover {
    background: rgba(239, 68, 68, .12);
    border-color: rgba(239, 68, 68, .4);
    transform: scale(1.08);
}

.btn-add-stop {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 7px 13px;
    background: rgba(249, 115, 22, .06);
    border: 1px dashed rgba(249, 115, 22, .35);
    border-radius: var(--radius-sm);
    color: var(--color-accent);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .18s, border-color .18s, color .18s;
    align-self: flex-start;
}

.btn-add-stop i {
    font-size: 10px;
}

.btn-add-stop:hover {
    background: rgba(249, 115, 22, .12);
    border-color: rgba(249, 115, 22, .55);
}

.btn-add-stop--disabled,
.btn-add-stop:disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── BUTTONS ──────────────────────────────────── */
.rbtn {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: .18s ease;
    white-space: nowrap;
}

.rbtn-ghost {
    background: transparent;
    color: #6b7280;
    border: 1px solid rgba(0, 0, 0, .1);
}

.rbtn-ghost:hover {
    background: rgba(0, 0, 0, .04);
    color: var(--color-primary);
}

.rbtn-primary {
    background: var(--color-primary);
    color: #fff;
}

.rbtn-primary:hover {
    background: var(--color-brand);
    /* was: #3e5272 */
    box-shadow: 0 4px 12px rgba(46, 58, 77, .2);
}

.rbtn-danger {
    background: #ef4444;
    color: #fff;
}

.rbtn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, .25);
}

/* ── DELETE MODAL ─────────────────────────────── */
.delete-modal {
    text-align: center;
}

.delete-icon-wrap {
    padding: 28px 20px 0;
    display: flex;
    justify-content: center;
}

.delete-icon-circle {
    width: 56px;
    height: 56px;
    background: rgba(239, 68, 68, .08);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: 22px;
}

.delete-body {
    padding: 14px 20px 4px;
}

.delete-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0 0 6px;
}

.delete-msg {
    font-size: 12.5px;
    color: #9ca3af;
    margin: 0;
    line-height: 1.5;
}

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 900px) {
    .routes-wrapper {
        grid-template-columns: 1fr;
    }

    .map-card {
        position: static;
    }
}

@media (max-width: 600px) {
    .toolbar {
        flex-wrap: wrap;
    }

    .search-box {
        max-width: 100%;
    }
}