/* --- Estrutura e Fundo --- */
body, html {
    height: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #fff;
    overflow: hidden; /* Impede barras de rolagem causadas pelo blur */
}

/* Estilos para o formulário de Chaves de API */
.form-container-card {
    background-color: rgba(40, 40, 40, 0.8);
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    margin: 40px auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.form-header h2 {
    margin-bottom: 15px;
    font-size: 1.8em;
    color: #fff;
}

.form-header p {
    margin-bottom: 10px;
    color: #ccc;
}

.styled-form .form-group {
    margin-bottom: 20px;
}

.styled-form .form-label {
    display: block;
    margin-bottom: 8px;
    color: #ddd;
    font-weight: bold;
}

.styled-form .form-control {
    width: 100%;
    padding: 12px;
    background-color: rgba(20, 20, 20, 0.7);
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    font-size: 1em;
}

.styled-form .form-control:focus {
    outline: none;
    border-color: #8A2BE2; /* Roxo azulado */
    box-shadow: 0 0 8px rgba(138, 43, 226, 0.5);
}

.btn-block {
    width: 100%;
    padding: 15px;
    font-size: 1.1em;
    font-weight: bold;
}

/* Estilos aprimorados para formulários */
.styled-form .form-control {
    background-color: rgba(20, 20, 20, 0.7) !important;
    border: 1px solid #444 !important;
    color: #fff !important;
}

.styled-form .form-control:focus {
    border-color: #8A2BE2 !important; /* Roxo azulado */
    box-shadow: 0 0 8px rgba(138, 43, 226, 0.5) !important;
}

/* Estilo para o seletor de data/hora */
.styled-form input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

/* Custom File Upload */
.custom-file-upload {
    display: flex;
    align-items: center;
    gap: 15px;
}

.form-control-file {
    display: none; /* Esconde o input original */
}

.custom-file-upload .btn {
    flex-shrink: 0; /* Impede que o botão encolha */
}

.file-name {
    color: #ccc;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.button-group {
    display: flex;
    gap: 15px;
}

.button-group .btn {
    flex: 1;
}

.form-divider {
    border: none;
    border-top: 1px solid #444;
    margin: 30px 0;
}


.background-blur {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background-image: url('/static/img/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(4px);
    z-index: -1;
}

.app-shell {
    position: relative;
    z-index: 1;
    height: 100vh;
    display: flex;
}

.sidebar {
    width: 260px;
    flex: 0 0 260px;
    padding: 22px 18px;
    background: rgba(0, 0, 0, 0.25);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow-y: auto;
}

/* Sidebar Header & Brand */
.sidebar-header {
    padding-bottom: 22px;
    margin-bottom: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #fff;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.brand-name {
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.5px;
    color: #fff;
}

.brand-highlight {
    color: #fff;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.04);
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.8), rgba(29, 161, 242, 0.8));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-details {
    overflow: hidden;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mobile Topbar */
.mobile-topbar {
    display: none;
    align-items: center;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding: 14px 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
}

.menu-toggle {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    width: auto;
}

.mobile-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.4px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
    display: block;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sidebar-group {
    border: none;
    background: transparent;
}

.sidebar-group summary {
    cursor: pointer;
    list-style: none;
    padding: 12px 12px;
    font-weight: 600;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: background 160ms ease, border-color 160ms ease;
}

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

.sidebar-group summary::after {
    content: "›";
    opacity: 0.75;
    transform: rotate(0deg);
    transition: transform 160ms ease, opacity 160ms ease;
}

.sidebar-group[open] summary {
    background: rgba(0, 0, 0, 0.26);
    border-color: rgba(255, 255, 255, 0.18);
}

.sidebar-group[open] summary::after {
    opacity: 0.9;
    transform: rotate(90deg);
}

.sidebar-link {
    display: block;
    padding: 10px 12px 10px 14px;
    color: #ddd;
    text-decoration: none;
    font-size: 14px;
    margin: 8px 8px 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-left: 3px solid #8A2BE2; /* Efeito Neon Lateral em todos os botões permanentemente */
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.16);
    text-decoration: none;
    transform: translateY(-1px);
}

.sidebar-link.active {
    background: rgba(138, 43, 226, 0.22);
    border-color: rgba(138, 43, 226, 0.55);
    border-left: 3px solid #8A2BE2; /* Mantém igual */
    color: #fff;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    text-decoration: none;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* Dashboard top link */
.sidebar-link-dashboard {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.12), rgba(29, 161, 242, 0.08)) !important;
    border-color: rgba(138, 43, 226, 0.2) !important;
    border-left: 3px solid #8A2BE2 !important;
    padding-left: 14px !important;
    font-weight: 600;
    margin-bottom: 8px;
    transition: background 160ms ease, border-color 160ms ease !important;
}

.sidebar-link-dashboard:hover {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.2), rgba(29, 161, 242, 0.12)) !important;
    border-color: rgba(138, 43, 226, 0.35) !important;
}

.sidebar-link-dashboard.active {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.28), rgba(29, 161, 242, 0.15)) !important;
    border-color: rgba(138, 43, 226, 0.55) !important;
    border-left: 3px solid #8A2BE2 !important;
    padding-left: 14px !important;
}

.app-main {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 32px;
}

/* Scrollbar */
.app-main::-webkit-scrollbar {
    width: 6px;
}

.app-main::-webkit-scrollbar-track {
    background: transparent;
}

.app-main::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

.app-main::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Conteúdo Centralizado (Login, Registro) --- */
.center-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.glass-form {
    padding: 40px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: 320px;
    text-align: center;
}

.glass-form h1 {
    margin-bottom: 30px;
    font-weight: 500;
}

/* --- Conteúdo Geral (Páginas internas) --- */
.main-content {
    position: relative;
    z-index: 1;
    padding: 28px;
    margin: 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- Elementos de Formulário --- */
.input-group {
    position: relative;
    margin-bottom: 25px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    font-size: 16px;
    border-radius: 8px;
    outline: none;
    box-sizing: border-box;
}

input::placeholder, textarea::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

button, input[type="submit"] {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 25px;
    background-color: #8A2BE2;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

button:hover, input[type="submit"]:hover {
    background-color: #9932CC;
}

.account-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
}

.account-delete {
    margin-top: 10px;
}

button.danger, input[type="submit"].danger {
    background-color: rgba(255, 70, 70, 0.85);
}

button.danger:hover, input[type="submit"].danger:hover {
    background-color: rgba(255, 70, 70, 0.95);
}

/* --- Botões --- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #1DA1F2; /* Cor primária do Twitter/X */
    color: #fff;
    border: 1px solid #1DA1F2;
}

.btn-primary:hover {
    background-color: #0d8ddb;
    border-color: #0d8ddb;
}

.btn-danger {
    background-color: #e0245e; /* Cor para ações perigosas, como excluir */
    color: #fff;
    border: 1px solid #e0245e;
}

.btn-danger:hover {
    background-color: #c9164d;
    border-color: #c9164d;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 14px;
}

/* Botão de conexão na área de contas */
.header-with-action .btn-primary {
    background-color: #1DA1F2;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(29, 161, 242, 0.4);
    border: none;
}

.header-with-action .btn-primary:hover {
    background-color: #0d8ddb;
    box-shadow: 0 6px 15px rgba(29, 161, 242, 0.6);
    transform: translateY(-1px);
}

/* --- Links e Navegação --- */
.links {
    margin-top: 20px;
}

.links a, nav a {
    color: #ddd;
    text-decoration: none;
    font-size: 14px;
    margin: 0 10px;
}

.links a:hover, nav a:hover {
    text-decoration: underline;
}

.sidebar nav a:hover {
    text-decoration: none;
}

nav {
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
}

/* --- Mensagens Flash --- */
.flashes {
    padding: 0;
    margin: 0;
}
.flashes li {
    list-style-type: none;
    padding: 10px;
    margin: 0 0 20px 0;
    border-radius: 5px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
}
.flashes .success { color: #d4edda; border: 1px solid #c3e6cb; }
.flashes .danger { color: #f8d7da; border: 1px solid #f5c6cb; }
.flashes .warning { color: #fff3cd; border: 1px solid #ffeeba; }
.flashes .info { color: #d1ecf1; border: 1px solid #bee5eb; }

/* --- Tabela de Posts --- */
.posts-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.posts-table th, .posts-table td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.posts-table thead th {
    color: #8A2BE2;
    font-weight: bold;
}

.posts-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.posts-table td a {
    color: #ddd;
    margin-right: 10px;
}

.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.account-card {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.account-card summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 14px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    user-select: none;
}

.account-card summary::-webkit-details-marker {
    display: none;
}

.account-card-title {
    font-weight: 700;
}

.account-card-meta {
    opacity: 0.75;
    font-size: 12px;
}

.account-form {
    padding: 0 14px 14px;
}

.account-form-row {
    margin-top: 12px;
}

.account-form-row label {
    display: block;
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 6px;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 22px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    text-align: center;
}

.empty-title {
    font-weight: 700;
    margin-bottom: 6px;
}

.empty-subtitle {
    opacity: 0.8;
    font-size: 14px;
}

@media (max-width: 900px) {
    body, html {
        overflow: auto;
    }

    .mobile-topbar {
        display: flex;
    }

    .app-shell {
        height: auto;
        min-height: 100vh;
        flex-direction: column;
        padding-top: 56px; /* space for topbar */
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 1001;
        background: rgba(20, 20, 20, 0.98);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid rgba(255, 255, 255, 0.15);
        border-bottom: none;
        flex: none;
    }
    
    .sidebar.open {
        left: 0;
    }

    .app-main {
        padding: 20px;
        overflow: visible;
        width: 100%;
        box-sizing: border-box;
    }
}
