/* ============================================
   EL JEFE DE OBRA INVISIBLE — VisionarIA
   Mobile-first, dark tech + construcción
   AI Hackers 80% + Efeso 20% + VisionarIA
   ============================================ */

:root {
    --bg-primary: #f5f6fa;
    --bg-card: #ffffff;
    --bg-input: #eef0f4;
    --border: #dce1e8;
    --text-primary: #1a1a2e;
    --text-secondary: #5a6070;
    --accent: #0693e3;
    --accent-light: #3aabf0;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --highlight: #0693e3;
    --radius: 16px;
    --radius-sm: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* HEADER */
.header {
    background: linear-gradient(135deg, #1a1a2e 0%, #2d3a5c 100%);
    padding: 20px 16px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 32px;
    background: rgba(255,255,255,0.15);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header h1 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: white;
}

.subtitle {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    font-weight: 500;
}

/* TABS */
.tabs {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 84px;
    z-index: 99;
    max-width: 600px;
    margin: 0 auto;
}

.tab {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.tab.active {
    color: var(--accent-light);
    border-bottom-color: var(--accent);
}

.tab-icon {
    font-size: 20px;
}

/* CONTENT */
.content {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 40px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* CARDS */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.card h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.4;
}

/* RECORD BUTTON */
.record-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 0;
}

.btn-record {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 4px solid var(--accent);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-record:active,
.btn-record.recording {
    border-color: var(--danger);
    background: rgba(225, 112, 85, 0.15);
    transform: scale(1.05);
}

.btn-record.recording {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(225, 112, 85, 0.4); }
    50% { box-shadow: 0 0 0 20px rgba(225, 112, 85, 0); }
}

.record-icon {
    font-size: 40px;
}

.timer {
    font-size: 24px;
    font-weight: 700;
    color: var(--danger);
    font-variant-numeric: tabular-nums;
}

/* UPLOAD AREA */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:active {
    border-color: var(--accent);
    background: rgba(122, 0, 223, 0.1);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.upload-area p {
    font-size: 14px;
    color: var(--text-secondary);
}

.preview-img {
    width: 100%;
    border-radius: var(--radius-sm);
    margin-top: 16px;
    max-height: 300px;
    object-fit: contain;
    background: var(--bg-input);
}

/* RESULTADO */
.resultado {
    margin-top: 20px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.resultado-header {
    margin-bottom: 16px;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: rgba(0, 184, 148, 0.15);
    color: var(--success);
}

/* CAMPOS */
.campo {
    margin-bottom: 12px;
}

.campo label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.valor-campo {
    background: var(--bg-input);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid var(--border);
}

.valor-campo.highlight {
    color: var(--highlight);
    font-weight: 700;
    font-size: 18px;
}

.valor-campo.transcripcion {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 13px;
}

.valor-campo.descripcion-larga {
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.6;
}

.datos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* INPUT FIELD */
.input-field {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
}

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 24px;
}

.kpi-grid .kpi-wide {
    grid-column: span 2;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.kpi {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 14px 10px;
    text-align: center;
    border: 1px solid var(--border);
}

.kpi.kpi-highlight {
    background: linear-gradient(135deg, rgba(6,147,227,0.08), rgba(0,184,148,0.08));
    border-color: rgba(6,147,227,0.25);
}

.kpi-valor {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -1px;
}

.kpi-highlight .kpi-valor {
    background: linear-gradient(90deg, #0693e3, #00b894);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 24px;
}

.kpi-label {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* CHARTS */
.chart-container {
    margin-bottom: 20px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid var(--border);
}

/* BUTTONS */
.btn-secondary {
    width: 100%;
    padding: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary:active {
    background: var(--border);
}

/* LOADING */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-content p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* NOTIFICACION */
.notificacion {
    position: fixed;
    bottom: 24px;
    left: 16px;
    right: 16px;
    max-width: 568px;
    margin: 0 auto;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.notificacion.success {
    background: var(--success);
    color: white;
}

.notificacion.error {
    background: var(--danger);
    color: white;
}

/* LISTADO DE PARTES */
.listado-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.partes-counter {
    background: var(--accent);
    color: white;
    font-size: 13px;
    font-weight: 700;
    min-width: 28px;
    height: 28px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
}

.partes-lista {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.partes-vacio {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 24px 0;
}

.parte-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    transition: border-color 0.2s;
}

.parte-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.parte-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.parte-trabajador-nombre {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.parte-fecha-hora {
    font-size: 11px;
    color: var(--text-secondary);
}

.btn-borrar-parte {
    background: none;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-borrar-parte:hover,
.btn-borrar-parte:active {
    background: rgba(225, 112, 85, 0.15);
    color: var(--danger);
    border-color: var(--danger);
}

.parte-card-obra {
    font-size: 13px;
    color: var(--accent-light);
    font-weight: 600;
    margin-bottom: 8px;
}

.parte-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.parte-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
}

.parte-tag.tipo {
    background: rgba(122, 0, 223, 0.15);
    color: var(--accent-light);
}

.parte-tag.horas {
    background: rgba(0, 206, 201, 0.15);
    color: var(--highlight);
}

.parte-tag.incidencia {
    background: rgba(225, 112, 85, 0.15);
    color: var(--danger);
}

.parte-card-desc {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

.parte-card-incidencia {
    margin-top: 8px;
    font-size: 12px;
    color: var(--danger);
    background: rgba(225, 112, 85, 0.08);
    padding: 8px 10px;
    border-radius: 8px;
    border-left: 3px solid var(--danger);
    line-height: 1.4;
}

.parte-acciones {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.materiales-lista {
    padding: 0;
}

/* TARJETAS DE MATERIAL */
.material-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
}

.material-card:last-child {
    margin-bottom: 0;
}

.mat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.mat-ref {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-light);
    background: rgba(122, 0, 223, 0.15);
    padding: 2px 8px;
    border-radius: 6px;
    letter-spacing: 0.3px;
}

.mat-importe {
    font-size: 15px;
    font-weight: 700;
    color: var(--highlight);
}

.mat-nombre {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.mat-detalle {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

/* BOTONES ACCION ALBARAN */
.albaran-acciones {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-accion {
    flex: 1;
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-guardar {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-guardar:active {
    background: #6500c0;
}

.btn-editar {
    background: var(--bg-input);
    color: var(--text-primary);
}

.btn-editar:active {
    background: var(--border);
}

.btn-exportar {
    background: var(--bg-input);
    color: var(--highlight);
    border-color: var(--highlight);
}

.btn-exportar:active {
    background: rgba(0, 206, 201, 0.1);
}

.notificacion.info {
    background: var(--accent);
    color: white;
}

/* ============================================
   BANNER DEMO
   ============================================ */

.banner-demo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(253, 203, 110, 0.12);
    border: 1px solid rgba(253, 203, 110, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--warning);
    line-height: 1.4;
}

.banner-demo button {
    background: rgba(253, 203, 110, 0.2);
    border: 1px solid rgba(253, 203, 110, 0.4);
    color: var(--warning);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.banner-demo button:active {
    background: rgba(253, 203, 110, 0.35);
}

/* ============================================
   VISTA POR OBRA (TAB 3)
   ============================================ */

.obra-seccion {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
}

.obra-cabecera {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
}

.obra-nombre {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.obra-toggle {
    font-size: 16px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.obra-seccion.collapsed .obra-toggle {
    transform: rotate(-90deg);
}

.obra-seccion.collapsed .obra-resumen-grid,
.obra-seccion.collapsed .obra-detalle {
    display: none;
}

.obra-resumen-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 8px;
    padding: 0 16px 14px;
}

.obra-stat {
    text-align: center;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 10px 6px;
}

.obra-stat-valor {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: var(--accent-light);
    letter-spacing: -0.5px;
}

.obra-stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.obra-detalle {
    padding: 0 16px 14px;
}

.obra-sublista {
    margin-bottom: 12px;
}

.obra-sublista:last-child {
    margin-bottom: 0;
}

.obra-sublista-titulo {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.obra-item-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 6px;
}

.obra-item-card:last-child {
    margin-bottom: 0;
}

.obra-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.obra-item-nombre {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.obra-item-fecha {
    font-size: 11px;
    color: var(--text-secondary);
}

.obra-item-importe {
    font-size: 14px;
    font-weight: 700;
    color: var(--highlight);
}

.obra-item-meta {
    display: flex;
    gap: 6px;
}

.obra-sin-datos {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 8px 0;
    text-align: center;
}

/* MINIATURA AVANCE */
.avance-thumb {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin: 8px 0;
    border: 1px solid var(--border);
}

/* ============================================
   DASHBOARD EJECUTIVO (TAB 4)
   ============================================ */

.dash-section {
    margin-top: 24px;
}

.dash-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.2px;
}

/* Tarjetas resumen por obra */
.dash-obra-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 10px;
}

.dash-obra-header {
    margin-bottom: 8px;
}

.dash-obra-nombre {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.dash-obra-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.dash-obra-stats span {
    background: var(--bg-card);
    padding: 3px 8px;
    border-radius: 6px;
}

.dash-progress-bar {
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.dash-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0693e3, #00b894);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.dash-progress-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
}

/* Incidencias */
.dash-incidencia-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
}

.dash-inc-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.dash-inc-fecha {
    font-size: 11px;
    color: var(--text-secondary);
}

.dash-inc-obra {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-light);
    margin-bottom: 2px;
}

.dash-inc-trabajador {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.dash-inc-texto {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

/* Albaranes en dashboard */
.dash-albaran-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
}

.dash-alb-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.dash-alb-proveedor {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.dash-alb-importe {
    font-size: 14px;
    font-weight: 700;
    color: var(--highlight);
}

.dash-alb-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
}

/* ============================================
   FOOTER CONTACTO
   ============================================ */

.footer-contacto {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 20px 16px;
    text-align: center;
    margin-top: 40px;
}

.footer-logo {
    height: 36px;
    width: auto;
    margin-bottom: 8px;
    opacity: 0.9;
}

.footer-contacto p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 2px 0;
}

.footer-contacto a {
    color: var(--highlight);
    text-decoration: none;
}

.footer-contacto a:hover {
    text-decoration: underline;
}
