/* ═══════════════════════════════════════════════════════════════
   PEDIDOS A PROVEEDORES — Rediseño Industrial / Command Center
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* ── Variables ── */
:root {
    --dark:    #0a1628;
    --navy:    #1e3a5f;
    --blue:    #2563eb;
    --sky:     #38bdf8;
    --amber:   #f59e0b;
    --green:   #10b981;
    --red:     #ef4444;
    --violet:  #7c3aed;
    --teal:    #0369a1;
    --surface: #ffffff;
    --bg:      #eef2f7;
    --border:  #dde3ed;
    --text:    #0f172a;
    --muted:   #64748b;
    --radius:  14px;
    --shadow:  0 4px 24px rgba(10,22,40,.1);
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'IBM Plex Sans', sans-serif !important; background: var(--bg); color: var(--text); }

/* Override admin-container */
.admin-container { padding: 18px !important; max-width: 1400px; margin: 0 auto; }

/* Override admin-section */
.admin-section {
    background: var(--surface) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
    margin-bottom: 18px !important;
    overflow: hidden !important;
    border: 1px solid var(--border) !important;
    padding: 0 !important;
}

/* Override section-title — dark header bar */
.admin-section .section-title,
.section-title {
    font-family: 'IBM Plex Sans', sans-serif !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    letter-spacing: .06em !important;
    text-transform: uppercase !important;
    color: #fff !important;
    background: var(--navy) !important;
    padding: 17px 22px !important;
    margin: 0 !important;
    border-bottom: 3px solid var(--sky) !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    border-radius: 0 !important;
}
.admin-section .section-title i,
.section-title i { color: var(--sky) !important; }

/* ── Stats grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 18px;
}
.stat-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-left: 6px solid var(--blue);
    opacity: 0;
    transform: translateY(10px);
    transition: all .35s ease;
}
.stat-box:hover { transform: translateY(-3px); box-shadow: 0 10px 36px rgba(10,22,40,.15); }

#sb1 { border-left-color: var(--amber); }
#sb2 { border-left-color: var(--blue); }
#sb3 { border-left-color: var(--green); }
#sb4 { border-left-color: var(--red); }

.sbi {
    width: 58px; height: 58px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0;
}
.sbi.amber  { background: #fef3c7; color: #d97706; }
.sbi.blue   { background: #dbeafe; color: #2563eb; }
.sbi.green  { background: #d1fae5; color: #059669; }
.sbi.red    { background: #fee2e2; color: #dc2626; }

.sbn {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 38px; font-weight: 800;
    color: var(--dark); line-height: 1;
}
.sbl { font-size: 13px; color: var(--muted); margin-top: 5px; font-weight: 500; }

/* ── Filtros ── */
.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    padding: 20px 22px;
}

.ff { display: flex; flex-direction: column; gap: 6px; }
.ff label {
    font-size: 11px; font-weight: 700;
    color: var(--navy); text-transform: uppercase; letter-spacing: .06em;
}
.ff input, .ff select {
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-family: 'IBM Plex Sans', sans-serif;
    background: #f8fafc;
    color: var(--text);
    min-width: 155px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    min-height: 50px;
}
.ff input:focus, .ff select:focus {
    border-color: var(--blue);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ── Botones grandes (reemplazan sync-button / tool-button en esta página) ── */
.pp-btn,
.sync-button,
.tool-button {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 13px 22px !important;
    border-radius: 10px !important;
    border: none !important;
    font-family: 'IBM Plex Sans', sans-serif !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all .2s !important;
    min-height: 50px !important;
    white-space: nowrap !important;
    text-decoration: none !important;
    letter-spacing: .01em !important;
}
.pp-btn i, .sync-button i, .tool-button i { font-size: 15px !important; }

.sync-button {
    background: var(--blue) !important;
    color: #fff !important;
}
.sync-button:hover {
    background: #1d4ed8 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 20px rgba(37,99,235,.35) !important;
}
.tool-button { color: #fff !important; }
.tool-button:hover {
    filter: brightness(1.12) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,.2) !important;
}

/* ── Tabla ── */
.ptable-wrap { overflow-x: auto; }
.ptable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    font-family: 'IBM Plex Sans', sans-serif;
}
.ptable thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #fff;
    background: var(--dark);
    border-bottom: none;
    white-space: nowrap;
}
.ptable thead th:first-child { border-left: none; }
.ptable tbody tr {
    transition: background .12s;
    cursor: pointer;
}
.ptable tbody tr:nth-child(odd)  { background: #fff; }
.ptable tbody tr:nth-child(even) { background: #f5f8fc; }
.ptable tbody tr:hover { background: #eff6ff !important; }
.ptable tbody td {
    padding: 15px 16px;
    border-bottom: 1px solid #eaeff7;
    vertical-align: middle;
    font-size: 14px;
}
.ptable tbody tr:last-child td { border-bottom: none; }

/* Estado badges — más grandes */
.estado-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
    font-family: 'IBM Plex Sans', sans-serif;
}
.est-pendiente  { background: #fef3c7; color: #92400e; }
.est-en_camino  { background: #dbeafe; color: #1d4ed8; }
.est-entregado  { background: #d1fae5; color: #065f46; }
.est-cancelado  { background: #fee2e2; color: #991b1b; }

.entrega-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--muted);
}

/* ── Table-top bar ── */
.table-top {
    background: var(--dark) !important;
    padding: 17px 20px !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 0 !important;
}
.table-top .section-title {
    background: transparent !important;
    border-bottom: none !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #fff !important;
    font-size: 15px !important;
}
.count-badge {
    background: rgba(255,255,255,.15) !important;
    color: #fff !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    padding: 6px 18px !important;
    border-radius: 30px !important;
    border: 1px solid rgba(255,255,255,.2) !important;
    font-family: 'IBM Plex Sans', sans-serif !important;
}

/* ── Acciones de fila — más grandes ── */
.row-actions { display: flex; gap: 8px; }
.act-btn {
    height: 38px !important;
    min-width: 38px !important;
    padding: 0 12px !important;
    border-radius: 9px !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 13px !important;
    cursor: pointer !important;
    transition: all .15s !important;
    font-weight: 700 !important;
}
.act-btn.entregar { background: #d1fae5; color: #065f46; }
.act-btn.edit     { background: #dbeafe; color: #1d4ed8; }
.act-btn.del      { background: #fee2e2; color: #991b1b; }
.act-btn:hover    { filter: brightness(.88); transform: translateY(-1px); }

.empty-p { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty-p i { font-size: 44px; margin-bottom: 14px; display: block; opacity: .35; }
.empty-p p { font-size: 16px; font-weight: 500; }

/* ══ MODAL ══ */
.pp-modal-bg {
    display: none;
    position: fixed; inset: 0;
    background: rgba(10,22,40,.65);
    z-index: 500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}
.pp-modal-bg.open { display: flex; }
.pp-modal {
    background: var(--surface);
    border-radius: 18px;
    width: 96%; max-width: 650px;
    max-height: 92vh; overflow-y: auto;
    box-shadow: 0 40px 100px rgba(0,0,0,.35);
}

/* Modal header — dark */
.pp-modal-head {
    padding: 22px 26px;
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 1;
    border-radius: 18px 18px 0 0;
    border-bottom: 3px solid var(--sky);
}
.pp-modal-head h2 {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 18px; font-weight: 800;
    color: #fff;
    display: flex; align-items: center; gap: 10px;
    letter-spacing: .03em;
}
.pp-modal-head h2 i { color: var(--sky); }
.pp-close {
    width: 38px; height: 38px;
    border-radius: 10px; border: none;
    background: rgba(255,255,255,.15);
    color: #fff; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.pp-close:hover { background: rgba(255,255,255,.28); }

.pp-modal-body { padding: 26px; }

/* Form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .span2 { grid-column: span 2; }

.form-field { display: flex; flex-direction: column; gap: 7px; }
.form-field label {
    font-size: 11px; font-weight: 700;
    color: var(--navy); text-transform: uppercase; letter-spacing: .07em;
}
.form-field input,
.form-field select,
.form-field textarea {
    padding: 13px 15px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-family: 'IBM Plex Sans', sans-serif;
    color: var(--text);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    background: #f8fafc;
    width: 100%;
    min-height: 50px;
}
.form-field textarea { min-height: 90px; resize: vertical; }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--blue);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* Search autocomplete */
.search-wrap { position: relative; }
.search-results-drop {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff;
    border: 2px solid var(--border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 230px; overflow-y: auto;
    z-index: 100;
    box-shadow: 0 14px 36px rgba(0,0,0,.13);
    display: none;
}
.search-results-drop.open { display: block; }
.drop-item {
    padding: 13px 16px; cursor: pointer;
    transition: background .1s;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}
.drop-item:last-child { border-bottom: none; }
.drop-item:hover { background: #eff6ff; }
.drop-item .di-code { font-size: 11px; color: var(--muted); font-weight: 600; }
.drop-item .di-name { font-weight: 600; color: var(--text); font-size: 15px; }
.drop-item .di-extra { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Chip seleccionado */
.selected-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 15px;
    background: #eff6ff;
    border: 2px solid #bfdbfe;
    border-radius: 10px;
    margin-top: 8px; font-size: 14px;
}
.selected-chip .chip-name { font-weight: 700; color: var(--navy); flex: 1; }
.selected-chip .chip-code { font-size: 12px; color: var(--blue); font-weight: 600; }
.selected-chip button { border: none; background: none; color: #9ca3af; cursor: pointer; font-size: 18px; padding: 0; }

/* Tipo entrega */
.entrega-opts { display: flex; gap: 12px; flex-wrap: wrap; }
.entrega-opt {
    flex: 1; min-width: 165px;
    padding: 18px; border: 2px solid var(--border);
    border-radius: 12px; cursor: pointer;
    transition: all .2s; text-align: center;
    background: #f8fafc;
}
.entrega-opt.selected {
    border-color: var(--blue); background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.entrega-opt i { font-size: 26px; margin-bottom: 8px; display: block; }
.entrega-opt span { font-size: 14px; font-weight: 700; color: var(--text); display: block; }
.entrega-opt small { font-size: 12px; color: var(--muted); margin-top: 3px; display: block; }

.recogida-fields { display: none; }
.recogida-fields.show { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Modal footer */
.pp-modal-foot {
    padding: 18px 26px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 12px;
    position: sticky; bottom: 0; background: #fff;
    border-radius: 0 0 18px 18px;
}
.pp-modal-foot .tool-button,
.pp-modal-foot .sync-button {
    min-height: 50px !important;
    padding: 13px 24px !important;
    font-size: 15px !important;
}

/* Etiqueta de sección modal */
.pp-section-label {
    font-size: 11px; font-weight: 800;
    text-transform: uppercase; letter-spacing: .09em;
    color: var(--navy);
    margin: 24px 0 14px;
    padding-bottom: 9px;
    border-bottom: 3px solid var(--sky);
    display: flex; align-items: center; gap: 8px;
}
.pp-section-label i { color: var(--sky); }

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

@media (max-width: 700px) {
    /* Tabla → tarjetas en móvil */
    .ptable { display: block; }
    .ptable thead { display: none; }
    .ptable tbody { display: block; }
    .ptable tbody tr {
        display: block;
        margin: 0 0 14px;
        border-radius: 12px;
        border: 1px solid var(--border);
        box-shadow: 0 2px 10px rgba(0,0,0,.07);
        overflow: hidden;
        background: #fff !important;
    }
    .ptable tbody tr:hover { background: #f8faff !important; }
    .ptable tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        border-bottom: 1px solid #eef2f7;
        font-size: 14px;
    }
    .ptable tbody td:last-child { border-bottom: none; }

    /* Etiquetas automáticas */
    .ptable tbody td:nth-child(1)::before { content: "📅 Fecha"; }
    .ptable tbody td:nth-child(2)::before { content: "📦 Producto"; }
    .ptable tbody td:nth-child(3)::before { content: "🏭 Proveedor"; }
    .ptable tbody td:nth-child(4)::before { content: "📋 Líneas"; }
    .ptable tbody td:nth-child(5)::before { content: "🚚 F. Entrega"; }
    .ptable tbody td:nth-child(6)::before { content: "📍 Tipo"; }
    .ptable tbody td:nth-child(7)::before { content: "🔵 Estado"; }
    .ptable tbody td:nth-child(8)::before { content: "⚙️ Acciones"; }

    .ptable tbody td::before {
        font-size: 11px; font-weight: 700;
        text-transform: uppercase; letter-spacing: .05em;
        color: var(--muted); flex-shrink: 0; width: 100px;
    }

    /* Ocultar proveedor y lineas en móvil (visible en card) */
    .ptable tbody td:nth-child(4),
    .ptable tbody td:nth-child(6) { display: none; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .sbn { font-size: 30px; }
    .sbi { width: 48px; height: 48px; font-size: 20px; }
    .stat-box { padding: 16px 14px; }

    .filters-row { flex-direction: column; padding: 16px; }
    .ff input, .ff select { min-width: 100%; }
    .filters-row > div { width: 100%; }

    .sync-button, .tool-button {
        width: 100% !important;
        justify-content: center !important;
    }

    .table-top { flex-direction: column; align-items: stretch; }
    .table-top > div { display: flex; gap: 10px; }
    .table-top .sync-button { flex: 1; justify-content: center !important; }

    .form-grid, .form-grid .span2 { grid-template-columns: 1fr !important; }
    .form-grid .span2 { grid-column: span 1 !important; }
    .recogida-fields.show { grid-template-columns: 1fr !important; }

    .entrega-opt { min-width: calc(50% - 6px); padding: 14px; }
    .pp-modal-body { padding: 18px; }
    .pp-modal-head { padding: 18px 20px; }
    .pp-modal-foot { padding: 14px 18px; flex-direction: column; }
    .pp-modal-foot button { width: 100%; justify-content: center !important; }

    .row-actions { flex-wrap: wrap; }
    .act-btn { min-width: 44px !important; height: 44px !important; }
}
