/* Reset básico */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

html {
    overflow-y: scroll; /* evita o “pulo” lateral ao aparecer/desaparecer o scroll */
}

/* Temas ------------------------------------------------------ */

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
}

/* Tema escuro */
body.theme-dark {
    --bg-body: #020617;
    --bg-elevated: #0f172a;
    --bg-sidebar: #020617;
    --bg-topbar: #020617;

    --border-subtle: #1f2937;

    --text-main: #e5e7eb;
    --text-muted: #9ca3af;

    --accent: #22c55e;
    --accent-soft: rgba(34, 197, 94, 0.16);

    --sidebar-active: #111827;
    --sidebar-hover: #111827;
}

/* Tema claro */
body.theme-light {
    --bg-body: #f3f4f6;
    --bg-elevated: #ffffff;
    --bg-sidebar: #f9fafb;
    --bg-topbar: #ffffff;

    --border-subtle: #e5e7eb;

    --text-main: #111827;
    --text-muted: #6b7280;

    --accent: #16a34a;
    --accent-soft: rgba(22, 163, 74, 0.14);

    --sidebar-active: #e5f9ec;
    --sidebar-hover: #e5e7eb;
}

/* Links */
a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* Layout geral ----------------------------------------------- */

.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--bg-body);
    color: var(--text-main);
}

/* Sidebar */

.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-subtle);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    height: 56px; /* igual à topbar para alinhar */
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo {
    width: 56px;
    height: 56px;
    border-radius: 0;
    background: transparent;
    display: block;
    overflow: hidden;
}

.sidebar-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-club {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
}

/* Navegação da sidebar */

.sidebar-nav {
    padding: 0.75rem 0 1rem;
    flex: 1;
    overflow-y: auto;
}

/* Grupos (details/summary) */

.sidebar-group {
    margin-bottom: 0.4rem;
}

.sidebar-group summary {
    list-style: none;
    cursor: pointer;
    padding: 0.4rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-group summary::-webkit-details-marker {
    display: none;
}

.sidebar-group summary span {
    opacity: 0.9;
}

/* Lista + animação moderna */

.sidebar-group-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-out;
}

.sidebar-group[open] .sidebar-group-list {
    max-height: 500px;
}

.sidebar-group-list li {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}

.sidebar-group[open] .sidebar-group-list li {
    opacity: 1;
    transform: translateY(0);
}

.sidebar-group[open] .sidebar-group-list li:nth-child(1) { transition-delay: 0.02s; }
.sidebar-group[open] .sidebar-group-list li:nth-child(2) { transition-delay: 0.05s; }
.sidebar-group[open] .sidebar-group-list li:nth-child(3) { transition-delay: 0.08s; }
.sidebar-group[open] .sidebar-group-list li:nth-child(4) { transition-delay: 0.11s; }
.sidebar-group[open] .sidebar-group-list li:nth-child(5) { transition-delay: 0.14s; }
.sidebar-group[open] .sidebar-group-list li:nth-child(6) { transition-delay: 0.17s; }
.sidebar-group[open] .sidebar-group-list li:nth-child(7) { transition-delay: 0.20s; }
.sidebar-group[open] .sidebar-group-list li:nth-child(8) { transition-delay: 0.23s; }
.sidebar-group[open] .sidebar-group-list li:nth-child(9) { transition-delay: 0.26s; }
.sidebar-group[open] .sidebar-group-list li:nth-child(10){ transition-delay: 0.29s; }

/* Links */

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    color: inherit;
}

.sidebar-link i {
    font-size: 0.9rem;
    opacity: 0.85;
    width: 1.1rem;
    text-align: center;
}

.sidebar-link span {
    flex: 1;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    text-decoration: none;
}

.sidebar-link-active {
    background: var(--sidebar-active);
    border-left-color: var(--accent);
}

/* Tema claro específico no sidebar */
body.theme-light .sidebar {
    color: #111827;
    border-right: 1px solid #e5e7eb;
}

body.theme-light .sidebar-link {
    color: #111827;
}

body.theme-light .sidebar-link i {
    opacity: 0.65;
}

/* Área principal */

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-body);
}

/* Topbar */

.topbar {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.topbar-left strong {
    color: var(--text-main);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.95rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: linear-gradient(135deg, #22c55e, #4ade80);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #ffffff;
}

.topbar-theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.topbar-theme-toggle i {
    font-size: 1rem;
}

/* Conteúdo */

.content {
    flex: 1;
    padding: 1.25rem 1.5rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.card {
    background: var(--bg-elevated);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.35);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.card-body {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Rodapé */

.app-footer {
    padding: 0.75rem 1rem 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    text-align: center;
    margin-top: auto;
}

.app-footer a {
    color: var(--accent);
}

/* Login page ------------------------------------------------- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #22c55e33 0, transparent 55%),
                radial-gradient(circle at bottom, #0ea5e933 0, transparent 55%),
                var(--bg-body);
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-elevated);
    border-radius: 1rem;
    padding: 1.75rem 1.75rem 1.4rem;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 24px 50px rgba(15, 23, 42, 0.55);
    text-align: center; /* centra tudo por defeito */
}

.login-card form {
    margin-top: 0.75rem;
    text-align: left; /* inputs alinhados à esquerda */
}

.login-logo {
    width: 140px;
    height: 140px;
    border-radius: 0;
    background: transparent;
    display: block;
    overflow: hidden;
    margin: 0 auto 0.8rem; /* centrado */
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
}

.login-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.1rem;
}

.form-group {
    margin-bottom: 0.9rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
    color: var(--text-muted);
}

.form-input {
    width: 100%;
    border-radius: 0.55rem;
    border: 1px solid var(--border-subtle);
    padding: 0.55rem 0.65rem;
    font-size: 0.9rem;
    background: var(--bg-body);
    color: var(--text-main);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft);
}

.btn-primary {
    width: 100%;
    border-radius: 0.6rem;
    border: none;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    margin-top: 0.3rem;
}
.btn-primary:hover {
    opacity: 0.95;
}

.alert-error {
    padding: 0.55rem 0.7rem;
    border-radius: 0.55rem;
    border: 1px solid rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.09);
    color: #fecaca;
    font-size: 0.8rem;
    margin-bottom: 0.85rem;
}

body.theme-light .alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.login-footer {
    margin-top: 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.login-footer a {
    color: var(--accent);
}

/* Responsivo --------------------------------------------- */

@media (max-width: 900px) {
    .sidebar {
        display: none;
    }
    .content {
        padding: 1rem;
    }
}

/* Tabs de configurações ------------------------------------- */
.config-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.config-tab {
    display: inline-block;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.config-tab:hover {
    background: var(--sidebar-hover);
    text-decoration: none;
}

.config-tab-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 500;
}
