/**
 * NK Instalaciones - Estilos principales
 * Diseño tablet-first con Bootstrap 5
 */

/* ════════════════════════════════════════════
   VARIABLES Y CONFIGURACIÓN GENERAL
   ════════════════════════════════════════════ */
:root {
    --nk-primary: #1a1a2e;
    --nk-accent: #e8b84b;
    --nk-success: #28a745;
    --nk-danger: #dc3545;
    --nk-bg: #f8f9fa;
    --nk-checked: #d4edda;
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--nk-bg);
    min-height: 100vh;
}

/* Área táctil mínima de 44x44px */
button, .btn, input[type="checkbox"], input[type="radio"], a.btn {
    min-height: 44px;
    min-width: 44px;
}

/* Inputs grandes para evitar zoom en iOS */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea,
select {
    font-size: 16px !important;
}

/* ════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════ */
.login-page {
    background: linear-gradient(135deg, var(--nk-primary) 0%, #2d2d44 100%);
}

/* ════════════════════════════════════════════
   DASHBOARD
   ════════════════════════════════════════════ */
.dashboard-container {
    min-height: 100vh;
}

.form-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.form-card:hover,
.form-card:active {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15) !important;
}

.form-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto;
}

/* ════════════════════════════════════════════
   CHECKLIST ITEMS
   ════════════════════════════════════════════ */
.checklist-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.checklist-item {
    padding: 16px 20px;
    border-bottom: 1px solid #dee2e6;
    transition: background-color 0.2s;
    cursor: pointer;
}

.checklist-item:last-child {
    border-bottom: none;
}

.checklist-item label {
    cursor: pointer;
    margin: 0;
    width: 100%;
    user-select: none;
}

.checklist-item input[type="checkbox"] {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    margin-right: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.checklist-item.checked {
    background-color: var(--nk-checked);
}

.checklist-label {
    flex: 1;
    line-height: 1.5;
}

.checklist-subgroup {
    background-color: #f8f9fa;
    padding: 12px 20px;
}

.subgroup-header {
    font-weight: 600;
    color: var(--nk-primary);
    margin-bottom: 12px;
    font-size: 0.95rem;
}

/* ════════════════════════════════════════════
   PROGRESS BAR
   ════════════════════════════════════════════ */
.progress-bar-container {
    z-index: 1020;
    border-bottom: 1px solid #dee2e6;
}

#progressText {
    font-weight: 600;
    font-size: 14px;
}

/* ════════════════════════════════════════════
   SIGNATURE PAD
   ════════════════════════════════════════════ */
.signature-container {
    border: 2px dashed #ced4da;
    border-radius: 8px;
    background-color: #fff;
    position: relative;
    overflow: hidden;
}

.signature-pad {
    width: 100%;
    height: 200px;
    touch-action: none;
    cursor: crosshair;
}

.signature-container::before {
    content: "Firme aquí";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #dee2e6;
    font-size: 1.2rem;
    pointer-events: none;
    z-index: 0;
}

.signature-pad.has-signature + .signature-container::before {
    display: none;
}

/* ════════════════════════════════════════════
   TABLA DINÁMICA DE PIEZAS
   ════════════════════════════════════════════ */
.table-piezas {
    font-size: 14px;
}

.table-piezas input,
.table-piezas select {
    font-size: 14px;
    padding: 8px;
}

.table-piezas .btn-remove-row {
    min-width: 40px;
    min-height: 40px;
}

/* Responsive: convertir tabla en tarjetas en móvil */
@media (max-width: 575.98px) {
    .table-piezas thead {
        display: none;
    }
    
    .table-piezas tbody tr {
        display: block;
        margin-bottom: 16px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 12px;
        background-color: #fff;
    }
    
    .table-piezas tbody td {
        display: block;
        text-align: left !important;
        padding: 8px 0;
        border: none;
    }
    
    .table-piezas tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        display: block;
        margin-bottom: 4px;
        color: var(--nk-primary);
    }
}

/* ════════════════════════════════════════════
   BOTONES DE ACCIÓN STICKY
   ════════════════════════════════════════════ */
.action-buttons-sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #fff;
    border-top: 2px solid #dee2e6;
    padding: 12px 0;
    z-index: 1030;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}

.action-buttons-sticky .btn {
    height: 56px;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Espacio inferior para evitar que el contenido quede oculto */
body {
    padding-bottom: 80px;
}

/* ════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ════════════════════════════════════════════ */
.toast {
    min-width: 250px;
}

/* ════════════════════════════════════════════
   ADMIN PANEL
   ════════════════════════════════════════════ */
.admin-sidebar {
    min-height: calc(100vh - 56px);
    background-color: var(--nk-primary);
}

.admin-sidebar .nav-link {
    color: rgba(255,255,255,0.8);
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.admin-sidebar .nav-link:hover,
.admin-sidebar .nav-link.active {
    background-color: rgba(255,255,255,0.1);
    color: #fff;
}

.admin-sidebar .nav-link i {
    width: 24px;
    text-align: center;
}

/* ════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ════════════════════════════════════════════ */

/* Tablets (768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .form-icon {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }
}

/* Móviles (< 768px) */
@media (max-width: 767.98px) {
    .form-icon {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }
    
    .action-buttons-sticky .btn {
        font-size: 1rem;
    }
    
    .checklist-item {
        padding: 12px 16px;
    }
    
    .checklist-item input[type="checkbox"] {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        margin-right: 12px;
    }
}

/* ════════════════════════════════════════════
   UTILIDADES
   ════════════════════════════════════════════ */
.text-primary {
    color: var(--nk-primary) !important;
}

.bg-primary {
    background-color: var(--nk-primary) !important;
}

.btn-primary {
    background-color: var(--nk-primary);
    border-color: var(--nk-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #0f0f1a;
    border-color: #0f0f1a;
}

/* Contraste alto para uso en obra */
.card {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Evitar selección de texto en elementos interactivos */
.btn, .form-card, .checklist-item label {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Spinner de carga */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-overlay .spinner-border {
    width: 4rem;
    height: 4rem;
}
