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

:root {
    --primary: #1f8d93;
    --primary-dark: #166d72;
    --primary-light: #e9f8f9;
    --accent: #2e7d32;
    --accent-light: #e8f5e9;
    --danger: #c62828;
    --danger-light: #ffebee;
    --text: #1c2b3a;
    --text-muted: #607080;
    --border: #d0dae5;
    --bg: #f4f7fb;
    --white: #ffffff;
    --shadow: 0 2px 12px rgba(31,141,147,.10);
    --radius: 10px;
    --radius-sm: 6px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
}

/* ── Navbar ─────────────────────────────────────────────────────── */
.navbar {
    background: var(--primary);
    color: var(--white);
    padding: 0 2rem;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: .5px;
    color: var(--white);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.navbar-brand img { display: block; }

.navbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    font-weight: 600;
    color: var(--white);
    letter-spacing: .3px;
    pointer-events: none;
    white-space: nowrap;
}

.navbar-links { display: flex; align-items: center; gap: 1rem; }
.navbar-links a {
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: .9rem;
    padding: .35rem .8rem;
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
}
.navbar-links a:hover { background: rgba(255,255,255,.12); color: var(--white); }
.navbar-links a.active { background: rgba(255,255,255,.18); color: var(--white); }

/* ── Page wrapper ───────────────────────────────────────────────── */
.page { max-width: 1200px; margin: 2.5rem auto; padding: 0 1.5rem 3rem; }
.page-narrow { max-width: 520px; }
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 1.55rem; font-weight: 700; color: var(--primary); }
.page-header p { color: var(--text-muted); font-size: .92rem; margin-top: .2rem; }

/* ── Card ───────────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.card-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.card-header h2 { font-size: 1rem; font-weight: 600; color: var(--text); }
.card-body { padding: 1.5rem; }

/* ── Description tag ─────────────────────────────────────────────── */
.desc-tag {
    display: inline-block;
    padding: .35rem 1.1rem;
    border-radius: 999px;
    font-size: .88rem;
    font-weight: 700;
    color: #fff;
    margin-top: .4rem;
    letter-spacing: .03em;
    text-transform: uppercase;
    line-height: 1.4;
}
.desc-preview {
    font-size: .88rem;
    font-weight: 700;
    color: #fff;
    padding: .35rem 1.1rem;
    border-radius: 999px;
    letter-spacing: .03em;
    text-transform: uppercase;
    line-height: 1.4;
    white-space: nowrap;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity .15s, transform .1s, box-shadow .15s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--accent); color: var(--white); }
.btn-success:hover { opacity: .88; }
.btn-danger  { background: var(--danger); color: var(--white); }
.btn-danger:hover  { opacity: .88; }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: .32rem .75rem; font-size: .82rem; }
.btn-icon { padding: .38rem .5rem; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-size: .88rem; font-weight: 500; margin-bottom: .4rem; color: var(--text); }
.form-control {
    width: 100%;
    padding: .55rem .85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .92rem;
    color: var(--text);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
    font-family: var(--font);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,77,124,.12);
}
.form-hint { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
    padding: .85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
}
.alert-success { background: var(--accent-light); color: var(--accent); border: 1px solid #a5d6a7; }
.alert-error   { background: var(--danger-light); color: var(--danger); border: 1px solid #ef9a9a; }
.alert-info    { background: var(--primary-light); color: var(--primary); border: 1px solid #90caf9; }

/* ── Public table page ───────────────────────────────────────────── */
.pub-hero {
    text-align: center;
    padding: 2.5rem 1rem 1.8rem;
}
.pub-hero h1 { font-size: 2rem; color: var(--primary); font-weight: 800; }
.pub-hero p  { color: var(--text-muted); margin-top: .5rem; font-size: 1rem; }

.table-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.5rem;
}
.tab-btn {
    padding: .45rem 1.1rem;
    border-radius: 999px;
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--white);
    color: var(--text-muted);
    transition: all .15s;
    text-decoration: none;
}
.tab-btn:hover, .tab-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.scroll-hint {
    display: none;
    text-align: center;
    font-size: .78rem;
    color: var(--text-muted);
    margin-bottom: .5rem;
    letter-spacing: .2px;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}
.filter-bar .form-control { max-width: 340px; }
.filter-count { font-size: .85rem; color: var(--text-muted); }

/* ── Price table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

.table-notice {
    margin-top: 1rem;
    padding: .8rem 1.2rem;
    border-radius: var(--radius);
    text-align: center;
    font-size: .9rem;
    font-weight: 600;
}

table.price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
table.price-table thead th {
    background: var(--primary);
    color: var(--white);
    padding: .8rem 1rem;
    text-align: left;
    font-weight: 600;
    letter-spacing: .3px;
    white-space: nowrap;
    position: relative;
}
table.price-table thead th:first-child { border-radius: var(--radius) 0 0 0; }
table.price-table thead th:last-child  { border-radius: 0 var(--radius) 0 0; }
table.price-table tbody tr { border-bottom: 1px solid var(--border); }
table.price-table tbody tr:last-child { border-bottom: none; }
table.price-table tbody tr:hover { background: none; }
table.price-table tbody td { padding: .7rem 1rem; vertical-align: top; }
table.price-table tbody tr.hidden-row { display: none; }

.no-results {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-muted);
    font-size: .95rem;
}

/* ── Admin layout ────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: calc(100vh - 60px); }

.sidebar {
    width: 220px;
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    flex-shrink: 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}
.sidebar-section { padding: .4rem 1rem; margin-bottom: .2rem; }
.sidebar-section label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-muted); }
.sidebar a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem 1.2rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .9rem;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.sidebar a:hover { background: var(--primary-light); color: var(--primary); }
.sidebar a.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }

.admin-content { flex: 1; padding: 2rem; min-width: 0; }

/* ── Table list (admin) ──────────────────────────────────────────── */
.tables-grid {
    display: grid;
    gap: 1rem;
}
.table-card {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    transition: box-shadow .15s;
}
.table-card:hover { box-shadow: var(--shadow); }
.table-card--default { border-color: var(--accent); }
.table-card-info h3 { font-size: 1rem; font-weight: 600; margin-bottom: .2rem; }
.table-card-info p  { font-size: .83rem; color: var(--text-muted); }
.table-card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-default { background: var(--accent-light); color: var(--accent); }
.badge-table   { background: var(--primary-light); color: var(--primary); }

/* ── Table builder (admin) ───────────────────────────────────────── */
.builder-controls {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.builder-controls label { font-size: .88rem; font-weight: 500; }
.builder-controls input[type=number] { width: 70px; }

.builder-table-wrap { overflow-x: auto; margin-bottom: 1.5rem; }

table.builder-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
table.builder-table th, table.builder-table td {
    border: 1.5px solid var(--border);
    padding: 0;
    min-width: 120px;
}
table.builder-table thead th {
    background: var(--primary-light);
    padding: 0;
}
table.builder-table thead th input {
    width: 100%;
    border: none;
    background: transparent;
    padding: .55rem .7rem;
    font-size: .88rem;
    font-weight: 600;
    color: var(--primary);
    font-family: var(--font);
}
table.builder-table thead th input:focus { outline: none; background: rgba(255,255,255,.6); }
table.builder-table thead th.row-num-col {
    width: 40px;
    min-width: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: .78rem;
    padding: .55rem .3rem;
    background: var(--bg);
}
table.builder-table tbody td input, table.builder-table tbody td textarea {
    width: 100%;
    border: none;
    background: transparent;
    padding: .5rem .7rem;
    font-size: .88rem;
    color: var(--text);
    font-family: var(--font);
    resize: none;
    min-height: 36px;
}
table.builder-table tbody td input:focus,
table.builder-table tbody td textarea:focus { outline: none; background: var(--primary-light); }
table.builder-table tbody td.row-num-col {
    width: 40px;
    min-width: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: .78rem;
    background: var(--bg);
    vertical-align: middle;
}
table.builder-table .del-row-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--danger);
    padding: .3rem;
    font-size: 1rem;
    opacity: .6;
    transition: opacity .15s;
}
table.builder-table .del-row-btn:hover { opacity: 1; }

/* ── Login page ──────────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 2.5rem 2rem;
}
.login-card .logo { text-align: center; margin-bottom: 1.8rem; }
.login-card .logo h1 { font-size: 1.5rem; color: var(--primary); font-weight: 800; }
.login-card .logo p { color: var(--text-muted); font-size: .88rem; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .admin-content { padding: 1.2rem; }
    .page { margin: 1rem auto; padding-left: .5rem; padding-right: .5rem; }
    .pub-hero h1 { font-size: 1.5rem; }
    table.price-table { font-size: .82rem; width: auto; min-width: 100%; }
    table.price-table thead th, table.price-table tbody td { padding: .6rem .7rem; white-space: nowrap; }

    /* Navbar: logo + links em cima, texto centralizado em baixo */
    .navbar {
        height: auto;
        padding: .5rem 1rem;
        flex-wrap: wrap;
        row-gap: .25rem;
    }
    .navbar-brand img { height: 48px !important; }
    .navbar-center {
        position: static;
        transform: none;
        order: 3;
        width: 100%;
        text-align: center;
        font-size: 1.1rem;
        padding-bottom: .25rem;
    }
    .navbar-links { gap: .5rem; }
    .navbar-links a { font-size: .83rem; padding: .25rem .5rem; }
}

@media (max-width: 480px) {
    .navbar-brand img { height: 40px !important; }
    .navbar-center { font-size: .95rem; }
    .navbar-links a { font-size: .78rem; }
}
