/* ============================================================================
   nubixstore Tools — Shared stylesheet
   Mobile-first. Paleta y tipografías según brand-manual.md
============================================================================ */

:root {
    /* Paleta oficial nubixstore */
    --c-dark:    #272e35;
    --c-deep:    #00033d;
    --c-royal:   #004a99;
    --c-cyan:    #00cfae;
    --c-mint:    #00dc86;
    --c-emerald: #1ca56a;

    /* Degradé principal (135deg, secuencia oficial) */
    --gradient: linear-gradient(135deg, #272e35 0%, #00033d 20%, #004a99 45%, #00cfae 70%, #00dc86 85%, #1ca56a 100%);

    /* UI */
    --bg:        #f4f6f9;
    --card:      #ffffff;
    --text:      #1a1d23;
    --muted:     #6c757d;
    --border:    #e1e4e8;
    --warn-bg:   #fff8e1;
    --warn-fg:   #856404;
    --warn-bd:   #ffc107;
    --ok-bg:     #d4edda;
    --ok-fg:     #155724;
    --ok-bd:     #28a745;
    --err-bg:    #f8d7da;
    --err-fg:    #721c24;
    --err-bd:    #dc3545;

    --radius:    10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow:    0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 6px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);

    --topbar-h:  56px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   TOP NAVIGATION (sticky en mobile y desktop)
============================================================================ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--gradient);
    color: white;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.topbar a, .topbar button {
    color: white;
    text-decoration: none;
}

.topbar .back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background .15s;
}
.topbar .back:hover, .topbar .back:active {
    background: rgba(255,255,255,.15);
}
.topbar .back svg { width: 22px; height: 22px; }

.topbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.topbar .brand img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.topbar .brand-text {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar .menu-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background .15s;
}
.topbar .menu-toggle:hover, .topbar .menu-toggle:active {
    background: rgba(255,255,255,.15);
}
.topbar .menu-toggle svg { width: 22px; height: 22px; }

/* Drawer (menú lateral con la lista de tools) */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 80%;
    max-width: 320px;
    background: white;
    z-index: 100;
    transform: translateX(100%);
    transition: transform .25s ease;
    overflow-y: auto;
    box-shadow: -4px 0 16px rgba(0,0,0,.15);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
    background: var(--gradient);
    color: white;
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.drawer-header img { width: 36px; height: 36px; }
.drawer-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.drawer-header small {
    display: block;
    font-size: 12px;
    opacity: .85;
    font-weight: 400;
}

/* Portal link (separado, fuera de categorías) */
.drawer-portal {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    transition: background .12s;
}
.drawer-portal:hover, .drawer-portal:active { background: #f4f6f9; }
.drawer-portal.active {
    background: rgba(0, 207, 174, .1);
    color: var(--c-royal);
}
.drawer-portal .t-icon {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    background: linear-gradient(135deg, var(--c-cyan), var(--c-mint));
    border-radius: 6px;
    color: white;
}

/* Categorías (accordions) */
.drawer-categories { padding: 4px 0; }

.drawer-category { border-bottom: 1px solid var(--border); }

.cat-header {
    width: 100%;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    transition: background .12s;
}
.cat-header:hover, .cat-header:active { background: #f4f6f9; }

.cat-header .c-icon {
    width: 24px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.cat-header .c-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-header .c-count {
    font-size: 11px;
    color: var(--muted);
    background: #eef0f3;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
    flex-shrink: 0;
}

.cat-header .chevron {
    width: 16px;
    height: 16px;
    color: var(--muted);
    transition: transform .2s;
    flex-shrink: 0;
}
.drawer-category.open .cat-header .chevron {
    transform: rotate(180deg);
}

.cat-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
    background: #fafbfc;
}
.drawer-category.open .cat-body {
    max-height: 500px;
}

.drawer-tool {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px 11px 32px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    border-top: 1px solid var(--border);
    transition: background .12s;
}
.drawer-tool:first-child { border-top: 1px solid var(--border); }
.drawer-tool:hover, .drawer-tool:active { background: #eef0f3; }

.drawer-tool.active {
    background: rgba(0, 207, 174, .12);
    color: var(--c-royal);
    font-weight: 600;
    border-left: 3px solid var(--c-cyan);
    padding-left: 29px;
}

.drawer-tool.disabled {
    color: var(--muted);
    pointer-events: none;
    opacity: .55;
}

.drawer-tool .t-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: linear-gradient(135deg, var(--c-cyan), var(--c-mint));
    border-radius: 5px;
    color: white;
    flex-shrink: 0;
}
.drawer-tool.disabled .t-icon { background: #ccc; }

.drawer-tool .t-name small {
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
    margin-left: 4px;
}

/* ============================================================================
   CONTAINERS / LAYOUT
============================================================================ */

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
}

@media (min-width: 768px) {
    .container { padding: 32px 24px; }
}

h1 {
    font-size: 24px;
    margin: 0 0 8px 0;
    letter-spacing: -.3px;
    line-height: 1.25;
}

@media (min-width: 768px) {
    h1 { font-size: 30px; }
}

.subtitle {
    color: var(--muted);
    font-size: 15px;
    margin: 0 0 24px 0;
}

.section { margin-bottom: 32px; }

.section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    font-weight: 600;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ============================================================================
   PORTAL GRID (tarjetas de herramientas)
============================================================================ */

.tools-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 600px) {
    .tools-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 992px) {
    .tools-grid { grid-template-columns: repeat(3, 1fr); }
}

.tool-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: transform .15s, box-shadow .15s, border-color .15s;
    border: 1px solid transparent;
    display: block;
}

.tool-card:active {
    transform: scale(.98);
}

@media (hover: hover) {
    .tool-card:hover {
        box-shadow: var(--shadow-lg);
        border-color: var(--c-cyan);
        transform: translateY(-2px);
    }
}

.tool-card.disabled {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}

.tool-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--c-cyan), var(--c-mint));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 14px;
}

.tool-card.disabled .tool-icon { background: #b8b8b8; }

.tool-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.tool-desc {
    color: var(--muted);
    font-size: 13.5px;
    margin: 0 0 12px 0;
    min-height: 38px;
}

.tool-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    color: var(--muted);
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
}

.badge.live { background: var(--ok-bg); color: var(--ok-fg); }
.badge.beta { background: var(--warn-bg); color: var(--warn-fg); }
.badge.soon { background: #e2e3e5; color: #495057; }

/* ============================================================================
   FORM ELEMENTS / INPUTS
============================================================================ */

input[type="text"],
input[type="search"],
input[type="number"],
textarea {
    width: 100%;
    padding: 14px;
    font-size: 16px; /* 16px previene zoom en iOS */
    font-family: 'Courier New', Consolas, monospace;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

input:focus, textarea:focus {
    border-color: var(--c-royal);
    box-shadow: 0 0 0 3px rgba(0, 74, 153, .15);
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--c-royal);
    color: white;
    min-height: 44px;
    transition: background .15s, transform .1s;
}

.btn:active { transform: scale(.98); }
.btn:hover { background: var(--c-deep); }

.btn.secondary {
    background: var(--muted);
}
.btn.secondary:hover { background: #545b62; }

.btn.outline {
    background: transparent;
    color: var(--c-royal);
    border: 2px solid var(--c-royal);
}
.btn.outline:hover {
    background: var(--c-royal);
    color: white;
}

/* ============================================================================
   CARD / BOX
============================================================================ */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.card h3 {
    margin: 0 0 12px 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    font-weight: 600;
}

.raw {
    font-family: 'Courier New', Consolas, monospace;
    font-size: 13px;
    background: #f9f9f9;
    padding: 12px;
    border-radius: var(--radius-sm);
    word-break: break-all;
    white-space: pre-wrap;
    border: 1px solid var(--border);
}

/* Stats grid */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
@media (min-width: 600px) {
    .stats { grid-template-columns: repeat(4, 1fr); gap: 10px; }
}

.stat {
    background: linear-gradient(135deg, rgba(0,74,153,.06), rgba(0,207,174,.06));
    padding: 10px;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border);
}
.stat .label {
    font-size: 10.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.stat .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--c-royal);
    margin-top: 2px;
}

/* Alerts */
.alert {
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    font-size: 14px;
    border-left: 4px solid;
}
.alert.warn { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn-fg); }
.alert.ok   { background: var(--ok-bg);   border-color: var(--ok-bd);   color: var(--ok-fg); }
.alert.err  { background: var(--err-bg);  border-color: var(--err-bd);  color: var(--err-fg); }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table th, table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-family: 'Courier New', Consolas, monospace;
}
table th {
    background: #f9f9f9;
    font-weight: 600;
    font-family: -apple-system, system-ui, sans-serif;
}

/* ============================================================================
   FOOTER
============================================================================ */

.footer {
    margin-top: 40px;
    padding: 20px 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}
.footer a { color: var(--c-royal); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ============================================================================
   UTILITIES
============================================================================ */

.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-2 { display: flex; gap: 10px; flex-wrap: wrap; }
.hidden { display: none !important; }
