/* ============================================
   CRUD genérico (tabla + toolbar + modal)
   ============================================ */

.crud-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.crud-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}
.crud-toolbar .search {
    flex: 1;
    min-width: 200px;
    position: relative;
}
.crud-toolbar .search input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: #f8fafc;
    outline: none;
    transition: border-color .15s, background .15s;
}
.crud-toolbar .search input:focus {
    border-color: #38bdf8;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}
.crud-toolbar .search::before {
    content: '🔍';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    opacity: .6;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    color: #fff;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(14,165,233,0.25);
    transition: transform .1s, filter .15s;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
    padding: 8px 14px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #475569;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
}
.btn-secondary:hover { background: #f1f5f9; }

.btn-danger {
    padding: 8px 14px;
    border-radius: 8px;
    background: #ef4444;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.btn-danger:hover { background: #dc2626; }

/* ---- Tabla ---- */
.crud-table-wrap {
    overflow-x: auto;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
}
.crud-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.crud-table thead th {
    text-align: left;
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.crud-table thead th.sort-asc::after  { content: ' ▲'; font-size: 10px; color: #38bdf8; }
.crud-table thead th.sort-desc::after { content: ' ▼'; font-size: 10px; color: #38bdf8; }
.crud-table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #0f172a;
}
.crud-table tbody tr:hover { background: #f8fafc; }

/* Altura uniforme de filas solo en escritorio */
@media (min-width: 769px) {
    .crud-table tbody tr { height: 60px; }
    .crud-table tbody td { height: 60px; vertical-align: middle; }
}
.crud-table .col-actions { text-align: right; white-space: nowrap; }
.crud-table .badge-on, .crud-table .badge-off {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
}
.crud-table .badge-on  { background: #dcfce7; color: #166534; }
.crud-table .badge-off { background: #fee2e2; color: #991b1b; }

.icon-btn {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    margin: 0;
    padding: 0;
    transition: background .15s, color .15s;
    cursor: pointer;
}
.icon-btn:hover { background: #f1f5f9; }
.icon-btn.edit:hover   { color: #0ea5e9; }
.icon-btn.delete:hover { color: #ef4444; background: #fef2f2; }

.empty-row td {
    text-align: center;
    color: #94a3b8;
    padding: 30px;
    font-size: 13px;
}

/* ---- Paginación ---- */
.crud-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 13px;
    color: #64748b;
}
.crud-pagination .pages {
    display: flex; gap: 4px;
}
.crud-pagination .pages button {
    min-width: 32px; height: 32px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #475569;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s;
}
.crud-pagination .pages button:hover { background: #f1f5f9; }
.crud-pagination .pages button.active {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #fff;
    font-weight: 700;
}
.crud-pagination .pages button:disabled { opacity: .4; cursor: not-allowed; }

/* ---- Form modal ---- */
.modal-form { max-width: 480px; }
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 12.5px;
    color: #475569;
    font-weight: 600;
    margin-bottom: 5px;
}
.form-group input[type=text],
.form-group input[type=number],
.form-group input[type=email],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #0f172a;
    background: #fff;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}
.form-group .hint { font-size: 11.5px; color: #94a3b8; margin-top: 4px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-checkbox {
    display: flex; align-items: center; gap: 8px;
    font-size: 13.5px; color: #0f172a;
}

/* ============ MODAL ============ */
.modal-backdrop {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(15,23,42,0.72);
    display: none;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    overflow-y: auto;
}
.modal-backdrop.show {
    display: grid;
    place-items: center;
}
.modal-backdrop.show > .modal { margin: auto; }
body.modal-open { overflow: hidden; }
.modal {
    width: 100%;
    max-width: 460px;
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 24px 48px rgba(0,0,0,0.25);
    animation: modal-in .18s ease-out;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
@keyframes modal-in {
    from { transform: translateY(8px) scale(0.98); opacity: 0; }
    to   { transform: none; opacity: 1; }
}
.modal-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 14px;
}
.modal-icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: #38bdf8;
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 20px;
}
.modal-danger .modal-icon { background: #ef4444; }
.modal-error  .modal-icon { background: #ef4444; }
.modal-header h3 { font-size: 17px; color: #0f172a; font-weight: 700; margin: 0; }
.modal-body p {
    color: #475569;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* Toast card (estilo notificación) */
.toast-stack {
    position: fixed; top: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 10px;
    z-index: 9999; pointer-events: none;
}
.toast {
    background: #fff; color: #1e293b;
    padding: 14px 16px 14px 14px;
    border-radius: 10px;
    border-left: 4px solid #64748b;
    box-shadow: 0 10px 30px rgba(15,23,42,.15), 0 2px 6px rgba(15,23,42,.06);
    font-size: 13.5px;
    min-width: 260px; max-width: 380px;
    display: flex; align-items: flex-start; gap: 12px;
    opacity: 0; transform: translateX(20px);
    transition: opacity .25s, transform .25s;
    pointer-events: auto;
}
.toast.show { opacity: 1; transform: none; }
.toast .toast-ico {
    width: 28px; height: 28px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0; font-weight: 700;
    background: #f1f5f9; color: #64748b;
}
.toast .toast-content { flex: 1; min-width: 0; }
.toast .toast-title { font-weight: 700; font-size: 13.5px; color: #0f172a; margin-bottom: 2px; }
.toast .toast-msg { font-size: 12.5px; color: #64748b; line-height: 1.4; }
.toast .toast-close {
    background: transparent; border: 0; cursor: pointer;
    color: #94a3b8; font-size: 16px; line-height: 1; padding: 2px 4px;
    align-self: flex-start;
}
.toast .toast-close:hover { color: #0f172a; }

.toast.warning { border-left-color: #f59e0b; }
.toast.warning .toast-ico { background: #fef3c7; color: #b45309; }
.toast.error   { border-left-color: #ef4444; }
.toast.error   .toast-ico { background: #fee2e2; color: #b91c1c; }
.toast.success { border-left-color: #10b981; }
.toast.success .toast-ico { background: #d1fae5; color: #065f46; }
.toast.info    { border-left-color: #3b82f6; }
.toast.info    .toast-ico { background: #dbeafe; color: #1d4ed8; }
