/* =====================================================================
   style.css  -  Diseno del panel Webhook Admin (moderno, profesional)
   ---------------------------------------------------------------------
   Estilo tipo SaaS: sidebar oscuro, area principal clara, tarjetas con
   sombras suaves, tipografia Inter, esquinas redondeadas y responsive.
   Organizado por secciones. Sin frameworks externos.
   ===================================================================== */

/* ---------- Tokens de diseno (variables) --------------------------- */
:root {
    /* Marca / acento */
    --brand:        #6366f1;   /* indigo 500 */
    --brand-600:    #4f46e5;
    --brand-700:    #4338ca;
    --brand-soft:   #eef2ff;   /* fondo suave del acento */

    /* Superficies */
    --bg:           #f6f7fb;   /* fondo general */
    --surface:      #ffffff;   /* tarjetas */
    --sidebar:      #0f172a;   /* slate 900 */
    --sidebar-2:    #1e293b;   /* hover en sidebar */

    /* Texto */
    --text:         #0f172a;
    --muted:        #64748b;   /* slate 500 */
    --on-dark:      #e2e8f0;
    --on-dark-mut:  #94a3b8;

    /* Bordes y estados */
    --border:       #e6e8ef;
    --ok:           #16a34a;  --ok-bg:   #dcfce7;  --ok-bd:  #bbf7d0;
    --err:          #dc2626;  --err-bg:  #fee2e2;  --err-bd: #fecaca;
    --info:         #2563eb;  --info-bg: #dbeafe;  --info-bd:#bfdbfe;
    --warn:         #d97706;  --warn-bg: #fef3c7;

    /* Sombras y radios */
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
    --shadow:    0 4px 16px rgba(15,23,42,.08);
    --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
    --r:    12px;
    --r-sm: 9px;
    --r-lg: 18px;
}

/* ---------- Base --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }

h1 { font-size: 1.5rem;  font-weight: 700; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0; }

.muted { color: var(--muted); }

.ic { flex: none; }

/* ===================================================================
   LAYOUT: sidebar + area principal
   =================================================================== */
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ----------------------------------------------- */
.sidebar {
    width: 256px;
    flex: none;
    background: var(--sidebar);
    color: var(--on-dark);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex; align-items: center; gap: .7rem;
    padding: 1.25rem 1.25rem;
    font-weight: 700; font-size: 1.05rem; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-mark {
    display: grid; place-items: center;
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), #8b5cf6);
    color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.45);
}

.sidebar-nav { padding: 1rem .75rem; flex: 1 1 auto; overflow-y: auto; }
.nav-label {
    display: block; padding: .9rem .75rem .35rem;
    font-size: .68rem; font-weight: 700; letter-spacing: .09em;
    text-transform: uppercase; color: var(--on-dark-mut);
}
.nav-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .75rem; margin: 2px 0;
    border-radius: var(--r-sm);
    color: var(--on-dark); font-weight: 500; font-size: .92rem;
    transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.is-active {
    background: linear-gradient(90deg, rgba(99,102,241,.25), rgba(99,102,241,.08));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand);
}
.nav-item.is-disabled { color: var(--on-dark-mut); cursor: default; }
.nav-item.is-disabled:hover { background: transparent; }
.nav-item .soon {
    margin-left: auto; font-style: normal; font-size: .62rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    background: rgba(255,255,255,.08); color: var(--on-dark-mut);
    padding: .12rem .4rem; border-radius: 999px;
}

.sidebar-foot {
    display: flex; align-items: center; gap: .6rem;
    padding: .85rem 1rem;
    border-top: 1px solid rgba(255,255,255,.07);
}
.me { display: flex; align-items: center; gap: .6rem; min-width: 0; flex: 1; }
.me-info { display: flex; flex-direction: column; min-width: 0; }
.me-info strong { color: #fff; font-size: .85rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info small { color: var(--on-dark-mut); font-size: .72rem; text-transform: capitalize; }
.sidebar-foot .logout {
    display: grid; place-items: center; width: 34px; height: 34px;
    border-radius: 9px; color: var(--on-dark-mut);
}
.sidebar-foot .logout:hover { background: rgba(239,68,68,.18); color: #fca5a5; }

.avatar {
    display: grid; place-items: center; flex: none;
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), #8b5cf6);
    color: #fff; font-weight: 700; font-size: .95rem;
}
.avatar.sm { width: 32px; height: 32px; font-size: .8rem; }

/* ---------- Area principal ---------------------------------------- */
.app-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex; align-items: center; gap: .75rem;
    height: 60px; padding: 0 1.5rem;
    background: rgba(255,255,255,.8);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.topbar-brand { font-weight: 700; }
.topbar-user {
    display: flex; align-items: center; gap: .55rem;
    padding: .25rem .55rem .25rem .25rem; border-radius: 999px;
    color: var(--text); font-weight: 500; font-size: .9rem;
    border: 1px solid var(--border); background: #fff;
}
.topbar-user:hover { background: var(--bg); color: var(--text); }

.icon-btn {
    display: grid; place-items: center; width: 38px; height: 38px;
    border: 1px solid var(--border); border-radius: 10px;
    background: #fff; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }

.content { padding: 1.75rem; max-width: 1120px; width: 100%; margin: 0 auto; flex: 1; }

.app-foot { padding: 1.25rem 1.75rem; text-align: center; color: var(--muted); }

.scrim { display: none; }

/* ---------- Visibilidad responsive -------------------------------- */
.only-mobile  { display: none; }
.only-desktop { display: inline; }

/* ===================================================================
   COMPONENTES
   =================================================================== */

/* ---------- Encabezado de pagina ---------------------------------- */
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.page-head .sub { color: var(--muted); margin: .25rem 0 0; font-size: .92rem; }

/* ---------- Botones ----------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .58rem .95rem; border-radius: var(--r-sm);
    border: 1px solid var(--border); background: #fff; color: var(--text);
    font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
    white-space: nowrap;
}
.btn:hover { background: var(--bg); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 18px; height: 18px; }

.btn-primary {
    background: var(--brand-600); border-color: var(--brand-600); color: #fff;
    box-shadow: 0 1px 2px rgba(79,70,229,.4);
}
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }

.btn-danger { background: #fff; border-color: var(--err-bd); color: var(--err); }
.btn-danger:hover { background: var(--err-bg); color: var(--err); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg); }

.btn-sm { padding: .38rem .6rem; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Tarjetas ---------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

/* ---------- Tarjetas de estadistica (dashboard) ------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 1.15rem 1.25rem; box-shadow: var(--shadow-sm);
    display: flex; align-items: center; gap: 1rem;
}
.stat .stat-ic {
    display: grid; place-items: center; width: 46px; height: 46px; flex: none;
    border-radius: 12px; background: var(--brand-soft); color: var(--brand-600);
}
.stat .stat-num { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat .stat-lbl { color: var(--muted); font-size: .85rem; margin-top: .15rem; }

/* ---------- Tarjetas-enlace (modulos) ----------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 1rem; }
.card-link {
    display: block; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 1.35rem; box-shadow: var(--shadow-sm);
    color: var(--text); transition: transform .12s, box-shadow .12s, border-color .12s;
}
.card-link:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #d7d9e3; color: var(--text); }
.card-link .ic-wrap {
    display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: .9rem;
    border-radius: 12px; background: var(--brand-soft); color: var(--brand-600);
}
.card-link h2 { display: flex; align-items: center; gap: .5rem; }
.card-link p { color: var(--muted); margin: .35rem 0 0; font-size: .9rem; }
.card-link.disabled { opacity: .65; pointer-events: none; }
.card-link.disabled .ic-wrap { background: #f1f5f9; color: var(--muted); }
.badge {
    font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    background: #f1f5f9; color: var(--muted); padding: .15rem .45rem; border-radius: 999px;
}

/* ---------- Tabla ------------------------------------------------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .85rem 1.1rem; text-align: left; }
.table thead th {
    background: #fafbfd; font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border);
}
.table tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: #fafbff; }
.table td.actions { display: flex; gap: .4rem; justify-content: flex-end; }
.cell-user { display: flex; align-items: center; gap: .7rem; }
.cell-user .name { font-weight: 600; }
.cell-user .sub  { color: var(--muted); font-size: .8rem; }
.inline { display: inline; margin: 0; }

/* ---------- Pills de estado --------------------------------------- */
.pill {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .2rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 600;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-on  { background: var(--ok-bg);  color: #15803d; }
.pill-off { background: var(--err-bg); color: #b91c1c; }
.tag { padding: .15rem .55rem; border-radius: 6px; font-size: .78rem; font-weight: 600;
    background: var(--brand-soft); color: var(--brand-700); text-transform: capitalize; }

/* ---------- Avisos (flash / errores) ------------------------------ */
.alert {
    display: flex; align-items: center; gap: .6rem;
    padding: .8rem 1rem; border-radius: var(--r-sm); margin-bottom: 1rem;
    border: 1px solid transparent; font-size: .92rem; font-weight: 500;
}
.alert-exito { background: var(--ok-bg);   border-color: var(--ok-bd);   color: #166534; }
.alert-error { background: var(--err-bg);  border-color: var(--err-bd);  color: #991b1b; }
.alert-info  { background: var(--info-bg); border-color: var(--info-bd); color: #1e40af; }

/* ---------- Formularios ------------------------------------------- */
.form { max-width: 560px; }
.form.wide { max-width: 820px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form .inline-row { display: flex; gap: .6rem; align-items: stretch; }
.form .inline-row select { flex: 1; }
.form textarea#texto { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9rem; min-height: 280px; }
.form label { display: block; margin: 1rem 0 .35rem; font-weight: 600; font-size: .85rem; }
.form .field:first-child label, .form > label:first-of-type { margin-top: 0; }
.form input[type=text], .form input[type=email], .form input[type=password], .form select, .form textarea {
    width: 100%; padding: .62rem .8rem; font: inherit; font-size: .95rem;
    color: var(--text); background: #fff;
    border: 1px solid var(--border); border-radius: var(--r-sm);
    transition: border-color .15s, box-shadow .15s;
}
.form textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form input:focus, .form select:focus, .form textarea:focus, .login-card input:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form .hint { display: block; margin-top: .35rem; color: var(--muted); font-size: .8rem; }
.form .check { display: flex; align-items: center; gap: .6rem; margin-top: 1.1rem; font-weight: 500; }
.form .check input { width: 18px; height: 18px; accent-color: var(--brand-600); }
.form .actions-row { display: flex; gap: .6rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* ===================================================================
   ORIGENES DE DATOS
   =================================================================== */
.req { color: var(--err); font-weight: 700; }
.pill-mut { background: #f1f5f9; color: var(--muted); }
.pill-mut::before { background: var(--muted); }

/* Caja de datos de conexion */
.config-box {
    border: 1px solid var(--border); border-radius: var(--r);
    padding: 1rem 1.25rem 1.25rem; margin: 1.25rem 0; background: #fcfcfe;
}
.config-box legend {
    display: flex; align-items: center; gap: .4rem;
    font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); padding: 0 .5rem;
}
.config-box legend .ic { width: 16px; height: 16px; }

/* Fila de prueba de conexion */
.test-row { display: flex; align-items: center; gap: .8rem; margin-top: 1rem; flex-wrap: wrap; }
.test-result { font-size: .88rem; font-weight: 600; }
.test-result.testing { color: var(--muted); }
.test-result.ok  { color: var(--ok); }
.test-result.err { color: var(--err); }

/* Catalogo de datos */
.op-card { margin-bottom: 1rem; }
.op-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.op-head h2 { font-size: 1.05rem; }
.op-desc { margin: .5rem 0 1rem; font-size: .9rem; }
.op-path { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem;
    color: var(--muted); background: var(--bg); padding: .15rem .5rem; border-radius: 6px; }
.method { font-size: .68rem; font-weight: 800; letter-spacing: .04em; color: #fff;
    padding: .18rem .5rem; border-radius: 6px; }
.method.m-get  { background: #16a34a; }
.method.m-post { background: #2563eb; }
.method.m-put  { background: #d97706; }
.method.m-delete { background: #dc2626; }

.io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: .5rem; }
.io-col { background: #fcfcfe; border: 1px solid var(--border); border-radius: var(--r-sm); padding: .9rem 1rem; }
.io-title { display: flex; align-items: center; gap: .4rem; font-weight: 700; font-size: .82rem;
    color: var(--text); margin-bottom: .6rem; }
.io-title .ic { width: 17px; height: 17px; color: var(--brand-600); }
.io-list { list-style: none; margin: 0; padding: 0; }
.io-list li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    padding: .4rem 0; border-bottom: 1px dashed var(--border); }
.io-list li:last-child { border-bottom: none; }
.io-key { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; font-weight: 700; color: var(--brand-700); }
.io-label { font-size: .85rem; }
.dtype { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
    background: var(--bg); padding: .08rem .4rem; border-radius: 5px; }
.req-tag { font-size: .66rem; font-weight: 700; text-transform: uppercase; color: var(--err);
    background: var(--err-bg); padding: .08rem .4rem; border-radius: 5px; }
.small { font-size: .85rem; }
.ref-token { margin-left: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .72rem;
    background: var(--brand-soft); color: var(--brand-700); border: 1px solid #dcdcfb;
    padding: .15rem .45rem; border-radius: 6px; cursor: pointer; }
.ref-token:hover { background: #e0e3ff; }
.ref-token.copied { background: var(--ok-bg); color: #166534; border-color: var(--ok-bd); }

@media (max-width: 860px) { .io-grid { grid-template-columns: 1fr; } }

/* ===================================================================
   PANTALLA DE LOGIN
   =================================================================== */
.auth-body {
    min-height: 100vh; margin: 0; display: grid; place-items: center; padding: 1.5rem;
    background:
        radial-gradient(1100px 500px at 100% -10%, rgba(139,92,246,.20), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(99,102,241,.20), transparent 55%),
        #0b1020;
}
.auth-wrap { width: 100%; max-width: 400px; }
.login-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
    padding: 2.25rem 2rem;
}
.login-brand {
    display: flex; flex-direction: column; align-items: center; gap: .85rem; margin-bottom: 1.5rem; text-align: center;
}
.login-brand .brand-mark { width: 52px; height: 52px; border-radius: 14px; }
.login-brand .brand-mark .ic { width: 26px; height: 26px; }
.login-brand h1 { font-size: 1.35rem; }
.login-brand p { color: var(--muted); margin: 0; font-size: .9rem; }
.login-card label { display: block; margin: 1rem 0 .35rem; font-weight: 600; font-size: .85rem; }
.login-card input {
    width: 100%; padding: .68rem .8rem; font: inherit; font-size: .95rem;
    border: 1px solid var(--border); border-radius: var(--r-sm); background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.login-card .btn { margin-top: 1.5rem; }
.login-foot { text-align: center; color: var(--on-dark-mut); font-size: .8rem; margin-top: 1.25rem; }

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 860px) {
    .only-mobile  { display: flex; }
    .only-desktop { display: none; }

    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 60;
        transform: translateX(-100%); transition: transform .25s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }

    .scrim.show {
        display: block; position: fixed; inset: 0; z-index: 50;
        background: rgba(15,23,42,.5);
    }

    .content { padding: 1.1rem; }
    .form .row { grid-template-columns: 1fr; }
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { padding: .6rem .25rem; }
    .table td { padding: .35rem 1rem; }
    .table td.actions { justify-content: flex-start; padding-top: .6rem; }
}
