/* Estilos del sistema de dibujos del mando */

.dt-hidden { display: none !important; }

/* Toolbar flotante — barra horizontal en el centro superior del mapa.
   z-index alto para no quedar bajo .em-detail (1200) ni .dt-panel. */
.dt-toolbar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1300;
    background: #1a2733;
    border: 1px solid #2a3a4a;
    border-radius: 10px;
    padding: 6px;
    display: flex;
    flex-direction: row;
    gap: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.dt-btn {
    width: 42px;
    height: 42px;
    background: transparent;
    color: #e0e0e0;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
}
.dt-btn:hover:not(:disabled) { background: #263545; }
.dt-btn.active { background: #2a5584; border-color: #4a90e2; }
.dt-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.dt-btn.dt-danger { color: #ff6b6b; }

/* Popover de subtipo — debajo de la toolbar (centro-superior). */
.dt-picker {
    position: absolute;
    top: 76px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1301;
    background: #1a2733;
    border: 1px solid #2a3a4a;
    border-radius: 10px;
    padding: 0;
    max-width: 420px;
    max-height: calc(100vh - 120px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* Pestañas */
.dt-picker-tabs {
    display: flex;
    border-bottom: 1px solid #2a3a4a;
    flex-shrink: 0;
}
.dt-picker-tab {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8899aa;
    background: transparent;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.dt-picker-tab:hover { color: #c0d0e0; background: #1f2c3a; }
.dt-picker-tab.active {
    color: #ff9100;
    border-bottom-color: #ff9100;
    background: #1f2c3a;
}
.dt-picker-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}
.dt-picker-page {
    display: none;
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}
.dt-picker-page.active { display: block; }
.dt-picker-group { margin-bottom: 10px; }
.dt-picker-group h5 {
    margin: 10px 0 6px 0;
    font-size: 0.75em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.dt-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}
.dt-picker-item {
    background: #0f1a22;
    border: 1px solid #2a3a4a;
    border-radius: 6px;
    padding: 8px 4px 6px;
    cursor: pointer;
    text-align: center;
    font-size: 12px;
    color: #e0e0e0;
    line-height: 1.2;
}
.dt-picker-item:hover { background: #2a5584; border-color: #4a90e2; }
.dt-picker-item img,
.dt-picker-item svg { width: 36px; height: 36px; display: block; margin: 0 auto 5px; }

/* Panel de metadatos */
.dt-panel {
    position: absolute;
    top: 70px;
    right: 16px;
    width: 340px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background: #1a2733;
    border: 1px solid #2a3a4a;
    border-radius: 10px;
    padding: 16px;
    z-index: 10;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    color: #e0e0e0;
}
.dt-panel h4 {
    margin: 14px 0 6px 0;
    font-size: 0.75em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.dt-panel label { display: block; font-size: 0.8em; margin-top: 8px; color: #aaa; }
.dt-panel input, .dt-panel textarea, .dt-panel select {
    width: 100%;
    padding: 6px 8px;
    background: #0f1a22;
    color: #e0e0e0;
    border: 1px solid #2a3a4a;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9em;
    box-sizing: border-box;
}
.dt-panel textarea { min-height: 60px; resize: vertical; }
.dt-measure {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.8em;
}
.dt-measure span { color: #8899aa; }
.dt-measure strong { color: #e0e0e0; font-weight: 600; }
.dt-altitude-profile {
    margin-top: 10px;
    color: #e0e0e0;
    font-size: 0.8em;
}
.dt-profile-head,
.dt-profile-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.dt-profile-head span,
.dt-profile-meta {
    color: #8899aa;
}
.dt-profile-head strong {
    color: #e0e0e0;
    font-weight: 600;
}
.dt-profile-chart {
    display: block;
    width: 100%;
    height: 64px;
    margin: 5px 0 3px;
}
.dt-profile-fill {
    fill: rgba(255, 107, 0, 0.18);
    stroke: none;
}
.dt-profile-line {
    fill: none;
    stroke: #ff9800;
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}
.dt-panel-actions {
    display: flex;
    gap: 6px;
    margin-top: 16px;
}
.dt-panel-actions button { flex: 1; padding: 8px; border-radius: 4px; cursor: pointer; }

/* Selector de dibujos solapados */
.dt-choice {
    min-width: 220px;
    color: #e0e0e0;
}
.dt-choice-title {
    margin: 0 0 8px;
    color: #ff9100;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.dt-choice-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    padding: 8px;
    background: #0f1a22;
    color: #e0e0e0;
    border: 1px solid #2a3a4a;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
}
.dt-choice-item:hover {
    background: #263545;
    border-color: #4a90e2;
}
.dt-choice-color {
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    border: 1px solid rgba(255,255,255,0.75);
    border-radius: 50%;
}
.dt-choice-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dt-choice-text strong,
.dt-choice-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dt-choice-text strong {
    font-size: 0.85rem;
    font-weight: 600;
}
.dt-choice-text small {
    color: #8899aa;
    font-size: 0.72rem;
}

/* Órdenes */
.dt-order {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    border-bottom: 1px solid #253545;
}
.dt-order-text { flex: 1; font-size: 0.85em; }
.dt-order-status { font-size: 1em; }

/* Custom fields */
.dt-custom-row { display: flex; gap: 4px; margin-top: 4px; }
.dt-custom-row input { flex: 1; }

/* Botón histórico (sidebar) */
.history-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #2a5584 0%, #1d4068 100%);
    color: #f0f6fc;
    border: 1px solid #3a6597;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.history-btn:hover {
    background: linear-gradient(135deg, #336aa3 0%, #234e7d 100%);
    border-color: #4f7ab0;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(42, 85, 132, 0.5);
}
.history-btn-icon { font-size: 1.1rem; opacity: 0.95; }
.history-btn-label { flex: 1; }

/* Modal histórico */
.dt-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: dt-modal-fade 0.2s ease;
}
@keyframes dt-modal-fade { from { opacity: 0; } to { opacity: 1; } }
.dt-modal-body {
    background: #1a2733;
    border: 1px solid #2a3a4a;
    border-radius: 12px;
    width: min(960px, 92vw);
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: #e0e0e0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: dt-modal-pop 0.22s cubic-bezier(.2,.8,.2,1);
}
@keyframes dt-modal-pop {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.dt-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #2a3a4a;
    background: linear-gradient(180deg, #1f2c3a 0%, #1a2733 100%);
}
.dt-modal-header h3 {
    margin: 0;
    color: #ff9100;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.dt-modal-header h3 .dt-modal-icon { font-size: 1.3rem; }
.dt-modal-close {
    background: transparent;
    border: 1px solid #3a4a5a;
    color: #aaa;
    width: 32px; height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: all 0.15s;
}
.dt-modal-close:hover { background: #3a2020; border-color: #ff5252; color: #ff5252; }

.dt-modal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    padding: 14px 20px;
    background: #15202c;
    border-bottom: 1px solid #2a3a4a;
}
.dt-modal-filters .dt-field { display: flex; flex-direction: column; gap: 4px; }
.dt-modal-filters .dt-field label {
    font-size: 0.7rem;
    color: #8899aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.dt-modal-filters input,
.dt-modal-filters select {
    background: #0f1923;
    color: #e0e0e0;
    border: 1px solid #2a3a4a;
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 0.85rem;
    min-width: 140px;
    transition: border-color 0.15s;
}
.dt-modal-filters input:focus,
.dt-modal-filters select:focus { outline: none; border-color: #4a90e2; }
.dt-modal-filters .dt-spacer { flex: 1; }
.dt-filter-btn {
    background: #2a5584;
    color: #fff;
    border: 1px solid #3a6597;
    padding: 7px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s;
}
.dt-filter-btn:hover { background: #336aa3; }

.dt-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 6px 12px 16px;
}
.dt-history-empty {
    text-align: center;
    padding: 60px 20px;
    color: #667788;
}
.dt-history-empty .dt-empty-icon { font-size: 2.5rem; opacity: 0.4; margin-bottom: 12px; }
.dt-history-count {
    padding: 8px 8px 4px;
    color: #8899aa;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tarjeta de fila histórica */
.dt-history-card {
    display: grid;
    grid-template-columns: 1fr 180px 110px 110px;
    gap: 14px;
    align-items: center;
    padding: 12px 14px;
    margin: 6px 0;
    background: #202f3c;
    border: 1px solid #2a3a4a;
    border-left: 3px solid #4a90e2;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.dt-history-card:hover {
    background: #263646;
    border-color: #3a4f64;
    border-left-color: #ff9100;
    transform: translateX(2px);
}
.dt-history-card .hc-main .hc-title {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 0.9rem;
    margin-bottom: 3px;
}
.dt-history-card .hc-main .hc-muni {
    color: #8899aa;
    font-size: 0.78rem;
}
.dt-history-card .hc-time {
    color: #b8c5d0;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}
.dt-history-card .hc-time .hc-time-label {
    color: #8899aa;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}
.dt-history-card .hc-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #8899aa;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.dt-history-card .hc-count .hc-count-num {
    font-size: 1.3rem;
    font-weight: 700;
    color: #4a90e2;
    margin-bottom: 1px;
}
.dt-history-card .hc-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    justify-self: end;
}
.dt-history-card .hc-status.active     { background: #1b3a1b; color: #4caf50; }
.dt-history-card .hc-status.controlled { background: #3a2e1b; color: #ff9800; }
.dt-history-card .hc-status.closed     { background: #2a2a2a; color: #888; }
.dt-history-card .hc-status .hc-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
}

@media (max-width: 700px) {
    .dt-history-card { grid-template-columns: 1fr; gap: 6px; }
    .dt-history-card .hc-status { justify-self: start; }
    .dt-modal-filters input,
    .dt-modal-filters select { min-width: 120px; }
}
