/* ==========================================================================
   PANEL TÉCNICO v8.1 - GOLD MASTER (Diseño Premium + Fix Grid + PC Center)
   ========================================================================== */

/* --- 1. VARIABLES Y BASE --- */
:root {
    --color-primary: #4f46e5;    /* Índigo vibrante */
    --color-primary-dark: #3730a3;
    --color-secondary: #64748b;  /* Texto secundario */
    --color-dark: #1e293b;       /* Texto principal */
    --color-bg: #f8fafc;         /* Fondo gris muy claro */
    --color-white: #ffffff;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--color-bg); color: var(--color-dark); line-height: 1.5; }
.hidden { display: none !important; }

/* --- 2. LOGIN --- */
.ta-login { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 20px; }
.ta-login-card { background: var(--color-white); padding: 40px 30px; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 400px; text-align: center; }
.ta-login-icon { font-size: 60px; margin-bottom: 20px; }
.ta-login-card h2 { margin: 0 0 10px; color: var(--color-dark); font-size: 26px; font-weight: 800; }

/* --- 3. INPUTS Y BOTONES --- */
.ta-input, .ta-textarea { width: 100%; padding: 16px; margin-bottom: 15px; border: 2px solid #e2e8f0; background: #f8fafc; border-radius: var(--radius-md); font-size: 16px; outline: none; transition: all 0.3s ease; color: var(--color-dark); font-weight: 500; }
.ta-input:focus, .ta-textarea:focus { border-color: var(--color-primary); background: var(--color-white); box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1); }
.btn { padding: 14px 24px; border-radius: var(--radius-md); font-weight: 700; border: none; cursor: pointer; font-size: 15px; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--color-primary); color: white; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3); }

/* --- 4. HEADER --- */
.ta-header { background: linear-gradient(135deg, var(--color-primary) 0%, #6366f1 100%); padding: 20px 25px 25px 25px; color: white; border-radius: 0 0 20px 20px; margin-bottom: 20px !important; position: relative; z-index: 10; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
.ta-header-top { display: flex; justify-content: space-between; align-items: start; }
.ta-header-date { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.9; font-weight: 600; }
.ta-header-name { font-size: 28px; font-weight: 900; margin-top: 4px; line-height: 1.2; }
.ta-header-logout { background: rgba(255,255,255,0.15); border: none; color: white; width: 44px; height: 44px; border-radius: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 20px; backdrop-filter: blur(5px); }

/* --- 5. BARRAS DE ESTADO --- */
.ta-bar { background: var(--color-white); margin: 0 20px 15px 20px; padding: 18px; border-radius: var(--radius-lg); display: flex; align-items: center; box-shadow: var(--shadow-md); position: relative; overflow: hidden; transition: transform 0.2s; }
.ta-bar::before { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 6px; background: var(--color-primary); }
.ta-bar:active { transform: scale(0.98); background: #fcfdff; }
.ta-bar-icon { font-size: 22px; margin-right: 18px; color: var(--color-primary); }
.ta-bar-title { font-weight: 800; font-size: 15px; color: var(--color-dark); }
.ta-bar-sub { font-size: 12px; color: var(--color-secondary); margin-top: 2px; }
.ta-toggle { padding: 8px 18px; border-radius: 50px; font-weight: 700; font-size: 12px; border: none; transition: all 0.3s ease; background: #dbeafe; color: var(--color-primary); }
.ta-toggle.off { background: #f1f5f9; color: #94a3b8; }

/* --- 6. GRID DE SECTORES (LO QUE SE ROMPIÓ EN TU FOTO) --- */
.ta-sector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); /* ESTO HACE LA MAGIA */
    gap: 15px;
    padding: 15px 20px 30px 20px;
}
.sector-card {
    background: var(--color-white); border: 1px solid #e2e8f0; border-radius: var(--radius-lg); padding: 20px; text-align: center; cursor: pointer; transition: all 0.2s; box-shadow: var(--shadow-md); display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 120px;
}
.sector-card:active { transform: scale(0.95); background: #f8fafc; }
.sector-card.active-task { border: 2px solid var(--color-success); background: #f0fdf4; }
.sector-icon { font-size: 30px; margin-bottom: 10px; }
.sector-name { font-weight: 800; color: var(--color-dark); font-size: 14px; text-transform: uppercase; margin-bottom: 5px; }
.sector-count { background: #eff6ff; color: var(--color-primary); padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: bold; }
.btn-back-sectors { display: inline-flex; align-items: center; gap: 8px; background: white; border: 1px solid #cbd5e1; color: var(--color-secondary); font-weight: 700; font-size: 13px; padding: 10px 16px; border-radius: 10px; margin: 15px 20px 5px 20px; cursor: pointer; box-shadow: var(--shadow-md); }

/* --- 7. TARJETAS DE ACTIVIDAD --- */
.ta-card { background: var(--color-white); border-radius: var(--radius-xl); box-shadow: var(--shadow-md); margin: 0 20px 25px 20px; overflow: hidden; border: 1px solid transparent; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); }
.ta-card.active { border-color: var(--color-primary); box-shadow: 0 15px 35px -5px rgba(79, 70, 229, 0.25); transform: translateY(-3px) scale(1.01); }
.card-header { padding: 20px 25px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid #f1f5f9; }
.meta-id { font-size: 11px; font-weight: 900; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.meta-date { font-size: 14px; font-weight: 700; color: var(--color-dark); }
.status-badge { padding: 6px 14px; border-radius: 50px; font-size: 11px; font-weight: 800; text-transform: uppercase; display: inline-flex; align-items: center; gap: 5px; }
.badge-default { background: #f1f5f9; color: #64748b; }
.badge-warn { background: #fff7ed; color: #d97706; border: 1px solid #fed7aa; }
.badge-info { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.badge-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.badge-dark { background: var(--color-dark); color: #f8fafc; }
.card-client { background: #f8fafc; padding: 20px 25px; border-bottom: 1px solid #f1f5f9; position: relative; }
.card-client::before { content: ''; position: absolute; left: 0; top: 20px; bottom: 20px; width: 4px; background: #cbd5e1; border-radius: 0 4px 4px 0; }
.ta-card.active .card-client::before { background: var(--color-primary); }
.label-client { font-size: 11px; font-weight: 800; color: #94a3b8; text-transform: uppercase; margin-bottom: 6px; }
.client-name { font-size: 18px; font-weight: 900; color: var(--color-dark); margin-bottom: 10px; line-height: 1.3; }
.client-phone { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--color-primary); font-size: 14px; font-weight: 700; background: rgba(79, 70, 229, 0.08); padding: 8px 16px; border-radius: 10px; }
.card-details { padding: 25px; }
.detail-row { display: flex; gap: 18px; margin-bottom: 20px; }
.detail-icon { font-size: 18px; width: 24px; text-align: center; color: var(--color-secondary); padding-top: 2px; }
.ta-card.active .detail-icon { color: var(--color-primary); }
.detail-title { font-size: 15px; font-weight: 700; color: var(--color-dark); margin-bottom: 4px; }
.detail-desc, .detail-text { font-size: 14px; color: var(--color-secondary); line-height: 1.5; }
.tracking-badge { background: #f1f5f9; color: var(--color-dark); padding: 4px 10px; border-radius: 6px; font-family: monospace; font-size: 13px; font-weight: 600; border: 1px solid #e2e8f0; }

/* --- 8. ACCIONES Y ETA --- */
.card-eta { padding: 15px 25px; background: #fff; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #f1f5f9; }
.card-eta label { font-size: 13px; font-weight: 700; color: var(--color-secondary); }
.eta-input { padding: 8px 12px !important; margin: 0 !important; font-size: 14px !important; width: 80px !important; height: 40px; text-align: center; }
.btn-icon { width: 40px; height: 40px; border-radius: 10px; border: none; background: var(--color-primary); color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.card-actions { padding: 20px 25px; display: flex; gap: 12px; background: #fff; }
.btn-full { flex: 1; padding: 16px; font-size: 15px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 800; }
.btn-mini { width: 54px; font-size: 20px; padding: 0; }
.btn-warn { background: var(--color-warning); color: white; }
.btn-success { background: var(--color-success); color: white; }
.btn-danger { background: var(--color-danger); color: white; }

/* --- 9. UTILIDADES Y MODALES --- */
.refresh-container { padding: 30px 20px; text-align: center; }
.btn-refresh { background: white; border: none; color: var(--color-secondary); padding: 12px 24px; border-radius: 50px; font-weight: 700; font-size: 13px; cursor: pointer; box-shadow: var(--shadow-md); display: inline-flex; align-items: center; gap: 8px; }
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.ta-modal-overlay { position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(15, 23, 42, 0.6); z-index:2000; display:none; align-items:center; justify-content:center; backdrop-filter: blur(8px); }
.ta-modal-box { background:white; width:90%; max-width:400px; padding:30px; border-radius:28px; box-shadow: var(--shadow-lg); animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.ta-actions { display:flex; justify-content:flex-end; gap:12px; margin-top:25px; }
.btn-ghost { background: transparent; color: var(--color-secondary); }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ta-toast { position:fixed; bottom:30px; left:50%; transform:translateX(-50%) translateY(100px); background: var(--color-dark); color:white; padding:14px 28px; border-radius:50px; font-weight: 600; font-size: 15px; box-shadow: var(--shadow-lg); transition: all 0.4s; z-index: 3000; display:flex; align-items:center; gap:10px; opacity:0; }
.ta-toast.visible { transform:translateX(-50%) translateY(0); opacity:1; }

/* SPINNER CORREGIDO */
.ta-loading-overlay { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(255,255,255,0.8); z-index:5000; display:none; align-items:center; justify-content:center; }
.ta-loading-overlay.visible { display:flex; }
.ta-spinner { width:40px; height:40px; border:4px solid #e2e8f0; border-top:4px solid var(--color-primary); border-radius:50%; animation:spin 0.8s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- 10. AJUSTE PC/TABLET (EL FINAL FIX) --- */
@media (min-width: 768px) {
    body { background-color: #e2e8f0; display: flex; justify-content: center; min-height: 100vh; }
    .ta-app { width: 100%; max-width: 480px; background: #f8fafc; box-shadow: 0 0 50px rgba(0,0,0,0.1); min-height: 100vh; position: relative; }
    .ta-login { position: absolute; }
}

/* --- 11. AJUSTE HEADER MÓVIL --- */
@media (max-width: 768px) {
    .ta-header {
        margin-bottom: 15px !important;
        padding-bottom: 20px;
    }
}

/* --- 12. BOTÓN FOTO EVIDENCIA --- */
.btn-foto-evidencia {
    background: #e0e7ff;
    color: #4338ca;
    border: 1px solid #a5b4fc;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    transition: all 0.2s;
    display: block;
    margin-top: 10px;
    text-decoration: none;
}
.btn-foto-evidencia:hover { background: #c7d2fe; }