/* ============================================================
   SICEH — Estilos globales
   Paleta institucional SAGARHPA · Gobierno de Sonora
   Guinda: #960e53  |  Hover: #72053f  |  Oscuro: #410123
   ============================================================ */

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

/* -- Body --------------------------------------------------- */
body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #ffffff;
    color: #111827;
}
.guest-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* -- Navbar ------------------------------------------------- */
.navbar {
    background: #960e53;
    color: #fff;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.navbar-brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .5px; }
.navbar-user  { font-size: .875rem; display: flex; align-items: center; gap: 1rem; }
.navbar-role  { background: rgba(255,255,255,.15); padding: .2rem .6rem; border-radius: 4px; font-size: .75rem; }
.navbar-nav   { display: flex; align-items: center; gap: .25rem; }
.nav-link {
    color: rgba(255,255,255,.8);
    font-size: .8rem;
    padding: .25rem .6rem;
    border-radius: 4px;
    text-decoration: none;
    transition: background .15s;
}
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.btn-logout {
    background: none;
    border: 1px solid rgba(255,255,255,.4);
    color: #fff;
    padding: .25rem .75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: .8rem;
    transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); }

/* -- Contenedor --------------------------------------------- */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* -- Tipografía --------------------------------------------- */
.page-title { font-size: 1.25rem; font-weight: 700; color: #410123; margin-bottom: 1.25rem; }
.header-row .page-title { margin-bottom: 0; }

/* -- Tarjetas ----------------------------------------------- */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    padding: 1.5rem;
}
.card-table {
    padding: 0;
    overflow: hidden;
}
.card-bordered {
    box-shadow: none;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    padding: 0;
}
.card-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: .875rem;
    color: #374151;
}
.card-body { padding: 1rem; }

/* -- Login -------------------------------------------------- */
.login-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
    border: 1px solid #e5e7eb;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}
.logo { text-align: center; margin-bottom: 1.5rem; }
.logo h1 { font-size: 1.5rem; font-weight: 700; color: #960e53; }
.logo p  { font-size: .8rem; color: #6b7280; margin-top: .25rem; }

/* -- Alertas ------------------------------------------------ */
.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    border-radius: 6px;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    font-size: .875rem;
}
.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 6px;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    font-size: .875rem;
}

/* -- Formularios -------------------------------------------- */
.form-group  { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .375rem; }
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-footer { display: flex; gap: .75rem; margin-top: 1.5rem; align-items: center; }

label { display: block; font-size: .875rem; font-weight: 500; color: #374151; }
label.field-label {
    font-size: .8rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .04em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: .9rem;
    color: #111827;
    transition: border-color .15s;
}
input[type="checkbox"] { width: auto; }
input:focus, select:focus {
    outline: none;
    border-color: #960e53;
    box-shadow: 0 0 0 3px rgba(150,14,83,.12);
}

.field-error  { color: #dc2626; font-size: .8rem; }
.field-static { font-size: .9rem; color: #6b7280; padding: .5rem 0; }
.section-label {
    display: block;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6b7280;
    margin: 1.5rem 0 .75rem;
    padding-bottom: .375rem;
    border-bottom: 1px solid #e5e7eb;
}
.remember    { display: flex; align-items: center; gap: .5rem; font-size: .875rem; color: #374151; }
.descripcion { font-size: .8rem; color: #6b7280; margin-top: .375rem; min-height: 1.2em; }

.opciones-grupo { margin-top: .75rem; display: none; }
.check-label { display: flex; align-items: flex-start; gap: .5rem; font-size: .8rem; color: #374151; cursor: pointer; margin-bottom: .375rem; }
.check-label input { margin-top: 2px; flex-shrink: 0; width: auto; }
.check-label code  { background: #f3f4f6; padding: .1rem .3rem; border-radius: 3px; font-size: .75rem; }

/* -- Botones — primario ------------------------------------- */
.btn-primary {
    display: inline-block;
    background: #960e53;
    color: #fff;
    padding: .5rem 1.25rem;
    border: 1px solid #000;
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    line-height: normal;
    transition: background .15s;
}
.btn-primary:hover { background: #72053f; }

/* -- Botones — secundario / cancelar ------------------------ */
.btn-cancel,
.btn-outline {
    display: inline-block;
    background: #fff;
    color: #410123;
    border: 1px solid #ccc;
    border-radius: 999px;
    padding: .5rem .75rem;
    font-size: .9rem;
    text-decoration: none;
    cursor: pointer;
    line-height: normal;
    transition: background .15s;
}
.btn-cancel:hover,
.btn-outline:hover { background: #f0f0f0; }

/* -- Botones — éxito (validación) --------------------------- */
.btn-success {
    display: inline-block;
    background: #16a34a;
    color: #fff;
    border: 1px solid #000;
    border-radius: 999px;
    padding: .45rem 1rem;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.btn-success:hover { background: #15803d; }

/* -- Botones — PDF / acción secundaria ---------------------- */
.btn-pdf {
    display: inline-block;
    background: #fff;
    color: #410123;
    border: 1px solid #ccc;
    border-radius: 999px;
    padding: .45rem 1rem;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.btn-pdf:hover { background: #f0f0f0; }

/* -- Botones — filtro --------------------------------------- */
.btn-filter {
    display: inline-block;
    padding: .375rem .75rem;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    font-size: .875rem;
    cursor: pointer;
    text-decoration: none;
}
.btn-filter:hover { background: #e5e7eb; }

/* -- Botones — peligro (eliminar) --------------------------- */
.btn-danger {
    background: none;
    border: 1px solid #fca5a5;
    color: #dc2626;
    padding: .2rem .6rem;
    border-radius: 4px;
    font-size: .8rem;
    cursor: pointer;
}
.btn-danger:hover { background: #fef2f2; }

/* -- Botones — agregar arete -------------------------------- */
.btn-add {
    padding: .4rem .9rem;
    background: #960e53;
    color: #fff;
    border: 1px solid #000;
    border-radius: 999px;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}
.btn-add:hover { background: #72053f; }

/* -- Botones — ejecutar script ------------------------------ */
.btn-run {
    width: 100%;
    margin-top: 1rem;
    padding: .625rem 1rem;
    background: #960e53;
    color: #fff;
    border: 1px solid #000;
    border-radius: 999px;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    transition: background .15s;
}
.btn-run:hover:not(:disabled) { background: #72053f; }
.btn-run:disabled { opacity: .6; cursor: not-allowed; }

/* -- Botones pequeños (tabla de usuarios) ------------------- */
.btn-sm {
    padding: .25rem .6rem;
    border-radius: 999px;
    font-size: .8rem;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid;
    display: inline-block;
}
.btn-edit       { border-color: #d1d5db; color: #374151; background: #fff; }
.btn-edit:hover { background: #f9fafb; }
.btn-toggle-off       { border-color: #fca5a5; color: #dc2626; background: #fff; }
.btn-toggle-off:hover { background: #fef2f2; }
.btn-toggle-on        { border-color: #6ee7b7; color: #059669; background: #fff; }
.btn-toggle-on:hover  { background: #f0fdf4; }

/* -- Tablas ------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
    text-align: left;
    padding: .625rem .75rem;
    border-bottom: 2px solid #e5e7eb;
    color: #6b7280;
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}
td {
    padding: .625rem .75rem;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
td code { background: #f3f4f6; padding: .1rem .35rem; border-radius: 3px; font-size: .75rem; }
.text-muted { color: #9ca3af; }
.actions    { display: flex; gap: .5rem; }

/* -- Badges ------------------------------------------------- */
.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 500;
}
.badge-sin-validar { background: #fef9c3; color: #854d0e; }
.badge-pendiente   { background: #dbeafe; color: #1e40af; }
.badge-validando   { background: #dbeafe; color: #1e40af; }
.badge-validado    { background: #dcfce7; color: #166534; }
.badge-active      { background: #dcfce7; color: #166534; }
.badge-inactive    { background: #fee2e2; color: #991b1b; }
.badge-role        { background: #dbeafe; color: #1e40af; }
.badge-ok  { background: #dcfce7; color: #166534; padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 600; }
.badge-err { background: #fee2e2; color: #991b1b;  padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 600; }

/* -- Paginación --------------------------------------------- */
.pagination { display: flex; gap: .375rem; margin-top: 1rem; font-size: .875rem; }
.pagination a,
.pagination span {
    padding: .25rem .6rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    text-decoration: none;
    color: #374151;
}
.pagination .active span { background: #960e53; color: #fff; border-color: #960e53; }

/* -- Header de sección -------------------------------------- */
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .75rem;
}

/* -- Dashboard ---------------------------------------------- */
.welcome   { margin-bottom: 1.5rem; }
.welcome p { color: #6b7280; font-size: .9rem; margin-top: .25rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    padding: 1rem 1.25rem;
    border-top: 3px solid #e5e7eb;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; color: #374151; }
.stat-card .stat-label { font-size: .8rem; color: #6b7280; margin-top: .25rem; }
.stat-total     { border-top-color: #6b7280; }
.stat-total .stat-value { color: #374151; }
.stat-borrador  { border-top-color: #ca8a04; }
.stat-borrador .stat-value  { color: #854d0e; }
.stat-pendiente { border-top-color: #3b82f6; }
.stat-pendiente .stat-value { color: #1e40af; }
.stat-validado  { border-top-color: #16a34a; }
.stat-validado .stat-value  { color: #166534; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.action-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: box-shadow .15s;
    border-left: 4px solid #960e53;
}
.action-card:hover  { box-shadow: 0 4px 10px rgba(0,0,0,.12); }
.action-card h3     { font-size: 1rem; font-weight: 600; color: #410123; margin-bottom: .25rem; }
.action-card p      { font-size: .825rem; color: #6b7280; }

/* -- Certificados — grid de info ---------------------------- */
.cert-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 2rem;
}
.cert-section     { min-width: 0; }
.cert-section-full { border-top: 1px solid #e5e7eb; margin-top: .5rem; padding-top: .25rem; }
@media (max-width: 640px) { .cert-info-grid { grid-template-columns: 1fr; } }

/* -- Certificados — detalle --------------------------------- */
.cert-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .75rem;
}
.cert-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
dl { display: grid; grid-template-columns: 160px 1fr; gap: .5rem .75rem; font-size: .9rem; }
dt { color: #6b7280; font-weight: 500; }
dd { color: #111827; }
a.ver       { color: #960e53; font-weight: 500; text-decoration: none; }
a.ver:hover { text-decoration: underline; }

/* -- Filtros de tabla --------------------------------------- */
.filter-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.filter-form select,
.filter-form input  { padding: .375rem .6rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: .875rem; width: auto; }

/* -- Aretes ------------------------------------------------- */
.aretes-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .875rem; }
.aretes-count  { font-size: .85rem; color: #6b7280; }
table.aretes th { padding: .5rem .75rem; }
table.aretes td { padding: .5rem .75rem; }
.add-arete-form {
    display: flex;
    gap: .5rem;
    align-items: flex-start;
    flex-wrap: nowrap;
    padding: .75rem;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}
.add-arete-form input {
    padding: .4rem .65rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: .875rem;
    flex: 1;
    min-width: 0;
    width: auto;
}
.add-arete-form select {
    padding: .4rem .35rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: .875rem;
    width: 7.5rem;
    flex-shrink: 0;
}

/* -- Admin: Scripts ----------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 1.25rem; align-items: start; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

.output-card   { margin-top: 1rem; }
.output-header { display: flex; align-items: center; gap: .5rem; padding: .625rem 1rem; border-bottom: 1px solid #e5e7eb; }
.output-pre {
    margin: 0;
    padding: .875rem 1rem;
    font-size: .78rem;
    background: #0f172a;
    color: #e2e8f0;
    max-height: 360px;
    overflow-y: auto;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}
.cmd-name { font-family: monospace; font-size: .8rem; color: #374151; }

/* -- Footer ------------------------------------------------- */
.footer { margin-top: 3rem; }

/* -- Utilidades --------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
    margin-right: .4rem;
}
.spinner-badge {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1.5px solid rgba(30,64,175,.25);
    border-top-color: #1e40af;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
    margin-right: .3rem;
}
