/* ===== Reusable components ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
    line-height: 1.2;
    transition: filter .1s ease, transform .05s ease;
    text-decoration: none;
}
.btn:hover { filter: brightness(0.97); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-accent { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.btn-accent:hover { background: var(--color-accent-dark); }
.btn-success { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.btn-outline { background: transparent; border-color: var(--color-primary); color: var(--color-primary); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--color-text-muted); }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border: 1px solid var(--color-border);
}
.card + .card { margin-top: 16px; }
.card__title { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-tile__value { font-size: 1.7rem; font-weight: 800; color: var(--color-primary-dark); }
.stat-tile__label { color: var(--color-text-muted); font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

/* Forms */
.form-field { margin-bottom: 16px; }
.form-field label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: var(--color-text);
}
.form-field .hint { display: block; font-size: 0.78rem; color: var(--color-text-muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=file],
select, textarea {
    width: 100%;
    padding: 11px 12px;
    font-size: 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--color-text);
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
textarea { resize: vertical; min-height: 90px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.badge-pendiente { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-en_proceso { background: var(--color-info-bg); color: var(--color-info); }
.badge-completada { background: var(--color-success-bg); color: var(--color-success); }
.badge-novedad { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-ok { background: var(--color-success-bg); color: var(--color-success); }
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-operario { background: var(--color-primary-light); color: var(--color-primary); }
.badge-activo { background: var(--color-success-bg); color: var(--color-success); }
.badge-inactivo { background: #eceff3; color: var(--color-text-muted); }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert-danger { background: var(--color-danger-bg); color: #9d1a1a; border-color: #f6c6c6; }
.alert-success { background: var(--color-success-bg); color: #0f6b3f; border-color: #b9e6cd; }
.alert-info { background: var(--color-info-bg); color: #1746a2; border-color: #bcd4fb; }
.alert-warning { background: var(--color-warning-bg); color: #935107; border-color: #f5d9a8; }

/* Simple data table (lists, users) */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--color-border); background: #fff; }
table.simple { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.simple th, table.simple td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
table.simple th { background: var(--color-primary-light); color: var(--color-primary-dark); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .03em; }
table.simple tbody tr:hover { background: #f8fafc; }
table.simple td.wrap { white-space: normal; }

.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--color-text-muted);
}
.empty-state__icon { font-size: 2.4rem; margin-bottom: 10px; }

/* Modal */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 25, 40, 0.55);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    z-index: 1000;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}
.modal-lg { max-width: 1100px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal__close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--color-text-muted); line-height: 1; padding: 4px; }

/* Toasts */
.toast-stack {
    position: fixed; bottom: 20px; right: 20px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 1100;
    max-width: 320px;
}
.toast {
    background: var(--color-text);
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 0.86rem;
    animation: toast-in .15s ease;
}
.toast-danger { background: var(--color-danger); }
.toast-success { background: var(--color-success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Upload dropzone */
.dropzone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 32px 16px;
    text-align: center;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.dropzone.is-dragover, .dropzone:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.dropzone__icon { font-size: 2rem; margin-bottom: 8px; }

.spinner {
    width: 18px; height: 18px;
    border: 3px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
.spinner-dark { border-color: rgba(30,74,122,0.25); border-top-color: var(--color-primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px;
    text-align: center;
}
.login-card__logo { height: 64px; margin-bottom: 12px; object-fit: contain; }
.login-card h1 { font-size: 1.25rem; margin-bottom: 4px; }
.login-card p.text-muted { margin-bottom: 22px; }
.login-card form { text-align: left; }
