/* ==========================================================================
   Alex Bot Panel - Design System
   ========================================================================== */

:root {
    --bg: #0b1220;
    --bg-soft: #0f172a;
    --surface: #151f33;
    --surface-2: #1c2a44;
    --border: #24344f;
    --border-soft: #1c2a44;
    --text: #e6edf7;
    --text-soft: #9fb0c7;
    --text-muted: #6b7a93;
    --primary: #38bdf8;
    --primary-strong: #0ea5e9;
    --primary-soft: rgba(56, 189, 248, 0.12);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.12);
    --danger: #f87171;
    --warning: #fbbf24;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: radial-gradient(1200px 500px at 70% -10%, #14263f 0%, var(--bg) 55%)
        fixed, var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* ==========================================================================
   Buttons / inputs
   ========================================================================== */

button, .btn {
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.62rem 1.1rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #07111f;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.18s, transform 0.08s, box-shadow 0.18s;
    line-height: 1;
    white-space: nowrap;
}

button:hover, .btn:hover {
    background: var(--primary-strong);
    box-shadow: 0 6px 18px rgba(56, 189, 248, 0.28);
}

button:active, .btn:active {
    transform: translateY(1px);
}

button.btn-ghost, .btn.btn-ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}

button.btn-ghost:hover, .btn.btn-ghost:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    box-shadow: none;
}

button.btn-danger, .btn.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.4);
}

button.btn-danger:hover, .btn.btn-danger:hover {
    background: rgba(248, 113, 113, 0.12);
    box-shadow: none;
}

button.btn-sm, .btn.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

input, select, textarea {
    font-family: inherit;
    padding: 0.62rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    font-size: 0.9rem;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239fb0c7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    padding-right: 2.2rem;
}

textarea {
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
}

/* ==========================================================================
   Topbar / navigation
   ========================================================================== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.85rem 2rem;
    background: rgba(11, 18, 32, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.brand-logo {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    display: grid;
    place-items: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.35);
}

.brand-logo svg {
    width: 20px;
    height: 20px;
}

.brand .brand-name {
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: 0.2px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand .brand-name span {
    color: var(--primary);
}

.topnav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.topnav a.navlink {
    color: var(--text-soft);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.topnav a.navlink:hover {
    background: var(--surface-2);
    color: #fff;
}

.topnav a.navlink.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.topnav a.navlink svg {
    width: 16px;
    height: 16px;
}

.topnav a.logout {
    color: var(--danger);
    font-weight: 500;
    margin-left: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.topnav a.logout:hover {
    background: rgba(248, 113, 113, 0.12);
}

/* ==========================================================================
   Layout
   ========================================================================== */

main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.page-head {
    margin-bottom: 1.75rem;
}

.page-head h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.page-head p {
    color: var(--text-soft);
    font-size: 0.92rem;
    margin-top: 0.25rem;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-title h2 {
    font-size: 1.05rem;
    font-weight: 600;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card h2 svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
    flex: 0 0 auto;
}

.card > p {
    color: var(--text-soft);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ==========================================================================
   Stat cards (dashboard)
   ========================================================================== */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    transition: border-color 0.15s, transform 0.15s;
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.stat-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary);
}

.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.blue { background: rgba(99, 102, 241, 0.14); color: #a5b4fc; }
.stat-icon.amber { background: rgba(251, 191, 36, 0.12); color: var(--warning); }

.stat-icon svg { width: 21px; height: 21px; }

.stat-info .stat-num {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.stat-info .stat-label {
    color: var(--text-soft);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   Forms / grids
   ========================================================================== */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.field {
    margin-bottom: 1.1rem;
}

.field label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text-soft);
}

.field label .req { color: var(--danger); }
.field .hint { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.35rem; }
.field code {
    background: var(--bg-soft);
    padding: 0.15rem 0.4rem;
    border-radius: 5px;
    font-size: 0.85em;
    color: var(--primary);
}

.add-form {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    align-items: center;
}

.add-form input[type="text"], .add-form input[type="url"] {
    flex: 2;
    min-width: 220px;
}

.form-actions {
    display: flex;
    gap: 0.7rem;
    margin-top: 1.1rem;
    flex-wrap: wrap;
}

.form-inline {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.form-inline input { flex: 0 1 auto; }

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.4rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }

.alert-ok {
    background: var(--success-soft);
    color: var(--success);
    border-color: rgba(74, 222, 128, 0.25);
}

.alert-error {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.25);
}

.ok { color: var(--success); }
.erro { color: var(--danger); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    text-align: left;
    padding: 0.8rem 1rem;
    background: var(--surface-2);
    color: var(--text-soft);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td {
    background: rgba(56, 189, 248, 0.04);
}

tbody tr:not(:hover) td { transition: background 0.15s; }

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

.row-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.row-actions form.inline { display: contents; }

.inline { display: inline; }

/* ==========================================================================
   Badges
   ========================================================================== */

.cat-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.7rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.cat-dublado {
    background: rgba(30, 64, 175, 0.25);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.cat-legendado {
    background: rgba(88, 28, 135, 0.28);
    color: #d8b4fe;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.18rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge.badge-on {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.badge.badge-off {
    background: rgba(160, 174, 192, 0.12);
    color: var(--text-soft);
    border: 1px solid var(--border);
}

.badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ==========================================================================
   Login
   ========================================================================== */

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2.5rem 2.2rem;
    box-shadow: var(--shadow);
    width: 360px;
    text-align: center;
}

.login-card .brand-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    margin: 0 auto 1.2rem;
}

.login-card .brand-logo svg { width: 28px; height: 28px; }

.login-card h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
}

.login-card .subtitle {
    color: var(--text-soft);
    font-size: 0.88rem;
    margin: 0.2rem 0 1.6rem;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.login-card form button { width: 100%; padding: 0.75rem; margin-top: 0.3rem; }

/* ==========================================================================
   Empty state
   ========================================================================== */

.empty {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 2rem 0;
}

.hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.8rem;
}

.cat-label { display: block; color: var(--text-soft); font-size: 0.86rem; margin-bottom: 0.5rem; font-weight: 500; }

/* ==========================================================================
   Segment group (method tabs)
   ========================================================================== */

.seg {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.4rem;
}

.seg button.seg-btn {
    background: transparent;
    color: var(--text-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.seg button.seg-btn:hover { color: #fff; border-color: var(--text-soft); box-shadow: none; }
.seg button.seg-btn.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

.method-panel { display: none; }
.method-panel.active { display: block; }

/* ==========================================================================
   Search
   ========================================================================== */

.searchbar {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    max-width: 420px;
}

.searchbar input { flex: 1; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 720px) {
    .topbar { flex-direction: column; align-items: stretch; gap: 0.6rem; padding: 0.9rem 1.1rem; }
    .topnav { justify-content: flex-start; }
    main { padding: 1.25rem 1rem 3rem; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .btn-sm { padding: 0.45rem 0.6rem; }
}
