/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

/* === Login === */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #EAF700;
}

.login-card {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

.login-card h1 {
    font-size: 1.5rem;
    text-align: center;
    color: #333;
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.login-card .btn-primary,
.form-actions .btn-primary,
.page-header .btn-primary {
    background: #000;
    color: #fff;
}

.login-card .btn-primary:hover,
.form-actions .btn-primary:hover,
.page-header .btn-primary:hover {
    background: #333;
}

/* === Navbar === */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #EAF700;
    color: #333;
    padding: 12px 24px;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #333;
}

.navbar-links a {
    color: #555;
    text-decoration: none;
    margin-left: 20px;
    font-size: 0.9rem;
}

.navbar-links a:hover {
    color: #000;
}

/* === Container === */
.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px;
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h2 {
    font-size: 1.3rem;
    color: #333;
}

/* === Alerts === */
.alert {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.alert-success {
    background: #efe;
    color: #363;
    border: 1px solid #cfc;
}

.alert-warning {
    background: #fff8e1;
    color: #8a6d00;
    border: 1px solid #ffe082;
}

/* === Forms === */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    background: #fff;
}

input[readonly],
input[disabled],
select[disabled] {
    background: #c9c9c9;
    color: #555;
    cursor: default;
}

.form-group input:focus {
    outline: none;
    border-color: #EAF700;
    box-shadow: 0 0 0 2px rgba(234,247,0,0.3);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-group-sm {
    max-width: 220px;
}

.form-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}

.form-grid-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0 20px;
}

/* === Loading overlay === */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 18px;
}
.loading-overlay.active { display: flex; }
.loading-spinner {
    width: 64px;
    height: 64px;
    border: 6px solid #ddd;
    border-top-color: #EAF700;
    border-radius: 50%;
    animation: loading-spin 0.9s linear infinite;
}
@keyframes loading-spin { to { transform: rotate(360deg); } }
.loading-text {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

/* === Checkbox Group === */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin-bottom: 16px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 130px;
    font-size: 0.88rem;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #333;
    cursor: pointer;
}

.inline-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.inline-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.inline-field input,
.inline-field select {
    width: 220px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.85rem;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #ddd;
}

/* === Fieldset === */
fieldset {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 20px;
    background: #fff;
}

legend {
    font-weight: 700;
    font-size: 0.95rem;
    color: #333;
    padding: 0 8px;
}

/* === Tables === */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.table th,
.table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 0.88rem;
}

.table th {
    background: #f9f9f9;
    font-weight: 600;
    color: #555;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: center;
}

.table-form input,
.table-form select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.85rem;
}

.table-form td {
    padding: 4px 6px;
}

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

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s;
}

.btn-primary {
    background: #EAF700;
    color: #333;
}

.btn-primary:hover {
    background: #d4e000;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
    padding: 4px 8px;
    font-size: 0.8rem;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-success {
    background: #28a745;
    color: #fff;
}

.btn-success:hover {
    background: #218838;
}

.btn-blue {
    background: #007bff;
    color: #fff;
}

.btn-blue:hover {
    background: #0056b3;
}

.btn-red {
    background: #dc3545;
    color: #fff;
}

.btn-red:hover {
    background: #c82333;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.82rem;
    background: #eee;
    color: #333;
    border-radius: 3px;
}

.btn-sm:hover {
    background: #ddd;
}

.btn-sm.btn-blue {
    background: #007bff;
    color: #fff;
}

.btn-sm.btn-blue:hover {
    background: #0056b3;
}

.btn-sm.btn-red {
    background: #dc3545;
    color: #fff;
    display: inline-flex;
    align-items: center;
}

.btn-sm.btn-red:hover {
    background: #c82333;
}

.btn-sm.btn-warning {
    background: #f0ad4e;
    color: #fff;
    display: inline-flex;
    align-items: center;
}

.btn-sm.btn-warning:hover {
    background: #ec971f;
}

.btn-sm.btn-success {
    background: #28a745;
    color: #fff;
    display: inline-flex;
    align-items: center;
}

.btn-sm.btn-success:hover {
    background: #218838;
}

.row-pending {
    background: #fffbea;
}

.row-obsolete {
    background: #f7f7f7;
    color: #888;
}

.text-muted {
    color: #888;
    font-size: 0.85rem;
    font-style: italic;
}

.btn-block {
    display: block;
    width: 100%;
}

.actions {
    white-space: nowrap;
}

.actions .btn-sm {
    margin-right: 4px;
}

/* === Marialuisas table column widths === */
#mlTable th:nth-child(1),
#mlTable td:nth-child(1) { width: 30px; }   /* # */
#mlTable th:nth-child(2),
#mlTable td:nth-child(2) { width: 80px; }   /* Código */
#mlTable th:nth-child(3),
#mlTable td:nth-child(3) { width: 70px; }   /* Largo */
#mlTable th:nth-child(4),
#mlTable td:nth-child(4) { width: 70px; }   /* Alto */
#mlTable th:nth-child(5),
#mlTable td:nth-child(5) { width: 180px; }  /* Tamaño */
#mlTable th:nth-child(6),
#mlTable td:nth-child(6) { width: 85px; }   /* Costo x Pliego */
#mlTable th:nth-child(7),
#mlTable td:nth-child(7) { width: 80px; }   /* Área */
#mlTable th:nth-child(8),
#mlTable td:nth-child(8) { width: 70px; }   /* Pliego % */
#mlTable th:nth-child(9),
#mlTable td:nth-child(9) { width: 85px; }   /* Costo Matboard */
#mlTable th:nth-child(10),
#mlTable td:nth-child(10) { width: 36px; }  /* Eliminar */

/* === Spacers table column widths === */
#spacersTable th:nth-child(1),
#spacersTable td:nth-child(1) { width: 30px; }   /* # */
#spacersTable th:nth-child(2),
#spacersTable td:nth-child(2) { width: 160px; }  /* Tipo */
#spacersTable th:nth-child(3),
#spacersTable td:nth-child(3) { width: 160px; }  /* Descripción */
#spacersTable th:nth-child(4),
#spacersTable td:nth-child(4) { width: 70px; }   /* Largo */
#spacersTable th:nth-child(5),
#spacersTable td:nth-child(5) { width: 70px; }   /* Alto */
#spacersTable th:nth-child(6),
#spacersTable td:nth-child(6) { width: 80px; }   /* Metros Lineales */
#spacersTable th:nth-child(7),
#spacersTable td:nth-child(7) { width: 85px; }   /* Costo Lineal */
#spacersTable th:nth-child(8),
#spacersTable td:nth-child(8) { width: 85px; }   /* Costo Spacer */
#spacersTable th:nth-child(9),
#spacersTable td:nth-child(9) { width: 36px; }   /* Eliminar */

/* === Hide remove button on first row of dynamic tables === */
#marcosBody tr:first-child .remove-row,
#mlBody tr:first-child .remove-row,
#spacersBody tr:first-child .remove-row {
    display: none;
}

/* === Row number column === */
.row-num {
    width: 30px;
    text-align: center;
    color: #888;
    font-weight: 600;
}

/* === Status Badges === */
.status-active {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 10px;
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 10px;
    background: #f8d7da;
    color: #721c24;
}

/* === Icon Buttons === */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    min-width: 32px;
    min-height: 32px;
}

.btn-icon svg {
    vertical-align: middle;
}

.icon-plus {
    font-size: 1.1rem;
    font-weight: bold;
    margin-right: 4px;
}

/* === Form Hints === */
.form-hint {
    font-size: 0.8rem;
    color: #888;
    margin-top: -8px;
    margin-bottom: 14px;
}

/* === Form Card === */
.form-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* === Responsive === */
@media (max-width: 768px) {
    .form-row { flex-direction: column; gap: 0; }
    .form-group-sm { max-width: 100%; }
    .form-grid-2col { grid-template-columns: 1fr; }
    .form-grid-3col { grid-template-columns: 1fr; }
    .navbar { flex-direction: column; gap: 8px; }
}

/* --- Utility classes (Fase 6 — cleanup de inline styles para CSP estricta) --- */
.is-hidden { display: none !important; }
.icon-inline { vertical-align: -2px; margin-right: 4px; }
.select-wide { min-width: 300px; }
.select-medium { min-width: 180px; }
