@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ==========================================================================
   Design System & Temas (Light e Dark Mode)
   ========================================================================== */
:root {
    /* Tema Claro - Monocromático Clean & Minimalista */
    --bg-page: #f4f4f5;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-subtle: #f4f4f5;
    --border-subtle: #e4e4e7;
    --border-button: #e4e4e7;
    --border-hover: #a1a1aa;
    --text-main: #09090b;
    --text-muted: #71717a;
    --text-subtle: #a1a1aa;
    --accent-primary: #09090b;
    --accent-hover: #27272a;
    --accent-light: #f4f4f5;
    --success-bg: #09090b;
    --success-text: #ffffff;
    --danger-bg: #f4f4f5;
    --danger-text: #09090b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
}

[data-theme="dark"] {
    /* Tema Escuro - Monocromático Graphite & Slate Premium */
    --bg-page: #09090b;
    --bg-card: #141417;
    --bg-input: #1c1c21;
    --bg-subtle: #1c1c21;
    --border-subtle: #27272a;
    --border-button: #27272a;
    --border-hover: #3f3f46;
    --text-main: #fafafa;
    --text-muted: #a1a1aa;
    --text-subtle: #71717a;
    --accent-primary: #fafafa;
    --accent-hover: #e4e4e7;
    --accent-light: #1c1c21;
    --success-bg: #fafafa;
    --success-text: #09090b;
    --danger-bg: #27272a;
    --danger-text: #fafafa;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.6);
}

/* Base resets */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

img {
    pointer-events: none;
    -webkit-user-drag: none;
}

html {
    scroll-behavior: smooth;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: calc(24px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
    background-color: var(--bg-page);
}

/* ==========================================================================
   Componentes de Botões & Form Control
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none;
    user-select: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: var(--success-text);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-subtle);
    color: var(--text-main);
    border-color: var(--border-button);
}

.btn-secondary:hover {
    background-color: var(--border-hover);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-button);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--border-hover);
    background-color: var(--bg-subtle);
}

.btn-copy {
    background-color: var(--accent-primary);
    color: var(--success-text);
    border: 1px solid var(--border-button);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.btn-copy:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-copy.copied {
    background-color: var(--border-hover) !important;
    transform: scale(1.02);
}

.btn-danger {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-button);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-md);
    aspect-ratio: 1;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    background-color: var(--bg-input);
    border: 1px solid var(--border-button);
    border-radius: var(--radius-md);
    outline: none;
    transition: all 0.2s ease;
}

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

/* ==========================================================================
   Layout Principal da Página Bio / Hub (index.html e 404.html)
   ========================================================================== */
.container {
    text-align: center;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: 440px;
    width: 100%;
    margin: 0 auto;
}

.theme-toggle-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 99;
    background: var(--bg-card);
    border: 1px solid var(--border-button);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    transform: rotate(15deg) scale(1.05);
    border-color: var(--border-hover);
}

.logo-wrapper {
    display: inline-block;
    margin-bottom: 12px;
    position: relative;
}

.logo {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--border-button);
    background-color: #ffffff;
    display: block;
    box-shadow: var(--shadow-sm);
}

.container h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 6px 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-main);
}

.verified-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Grupos & Botões de Bio */
.groups-section {
    margin-bottom: 24px;
    width: 100%;
}

.groups-section h3 {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 12px;
    color: var(--text-subtle);
}

.groups-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
}

.link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    padding: 13px 14px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.01em;
    border: none;
    color: #ffffff;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.link:hover {
    transform: translateY(-2px);
    opacity: 0.96;
}

.link:active {
    transform: translateY(0);
}

.icon {
    width: 18px;
    height: 18px;
    color: #ffffff;
    display: inline-block;
    flex-shrink: 0;
}

.link span {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
}

/* Gradientes dos Botões de Grupo */
.link.whatsapp {
    background: linear-gradient(135deg, #25d366 0%, #10b981 100%);
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.25);
}

.link.telegram {
    background: linear-gradient(135deg, #0088cc 0%, #0284c7 100%);
    box-shadow: 0 4px 14px rgba(0, 136, 204, 0.25);
}

.link.instagram {
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    box-shadow: 0 4px 14px rgba(225, 48, 108, 0.25);
}

.link.shopee {
    background: linear-gradient(135deg, #ee4d2d 0%, #ff7337 100%);
    box-shadow: 0 4px 14px rgba(238, 77, 45, 0.25);
}

.link.tiktok {
    background: linear-gradient(135deg, #0f172a 0%, #000000 100%);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
}

.link.contato {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
}

.link.brinde {
    background: var(--text-main);
    color: var(--bg-card);
    border: none;
    width: 100%;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

.link.brinde:hover {
    opacity: 0.9;
}

/* Seção de Novidades / Feed */
.posts-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
    width: 100%;
}

.posts-section h2 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 16px;
    color: var(--text-subtle);
}

.posts-container {
    width: 100%;
}

.posts-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.post-card {
    position: relative;
    display: block;
    text-decoration: none;
    border-radius: 14px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-button);
    transition: all 0.2s ease;
}

.post-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.post-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.post-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(15, 23, 42, 0.92) 0%,
        rgba(15, 23, 42, 0.3) 60%,
        rgba(0, 0, 0, 0) 100%
    );
    pointer-events: none;
    z-index: 1;
}

.post-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    line-height: 1.35;
    z-index: 2;
    text-align: left;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.posts-footer {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

/* Campo de busca no Bio / 404 */
.site-search-wrapper {
    margin-bottom: 20px;
    width: 100%;
}

.site-search-input-group {
    display: flex;
    gap: 8px;
}

.search-results {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.search-result-item {
    background: var(--bg-card);
    border: 1px solid var(--border-button);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.result-info strong {
    display: block;
    font-size: 13px;
    color: var(--text-main);
}

.result-info small {
    font-size: 11px;
    color: var(--text-muted);
}

/* ==========================================================================
   Painel Administrativo (admin.html) - Layout & Dashboard
   ========================================================================== */
.admin-body {
    background-color: var(--bg-page);
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: block;
    padding: 16px;
}

/* Navbar Admin */
.admin-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-card);
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-button);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-button);
}

.admin-brand h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Grid do Dashboard Admin */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 900px) {
    .admin-grid {
        grid-template-columns: 360px 1fr;
    }
}

/* Card Genérico Admin */
.admin-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-button);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.admin-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.admin-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Form de Criação de Link */
.create-link-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.form-help {
    font-size: 11px;
    color: var(--text-subtle);
}

.input-with-prefix {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-button);
    border-radius: var(--radius-md);
    background-color: var(--bg-input);
    overflow: hidden;
}

.input-prefix {
    padding: 0 10px;
    font-size: 13px;
    color: var(--text-muted);
    background-color: var(--bg-subtle);
    border-right: 1px solid var(--border-button);
    white-space: nowrap;
    user-select: none;
}

.input-with-prefix input {
    border: none;
    border-radius: 0;
    box-shadow: none !important;
}

/* Banner Feedback de Criação com Botão Copiar Link */
.created-success-banner {
    background: var(--accent-light);
    border: 1px dashed var(--accent-primary);
    padding: 14px;
    border-radius: var(--radius-md);
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.created-success-banner h4 {
    font-size: 14px;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.created-url-display {
    font-family: monospace;
    font-size: 13px;
    background: var(--bg-card);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-button);
    word-break: break-all;
}

/* Dashboard Metrics / Cards */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-button);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.metric-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.metric-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

/* Tabela e Busca de Links (Alta Performance) */
.link-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.link-search-bar input {
    flex: 1;
    min-width: 200px;
}

.links-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-button);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
}

.links-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.links-table th {
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    font-weight: 700;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-button);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
}

.links-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
    vertical-align: middle;
}

.links-table tr:hover {
    background-color: var(--bg-subtle);
}

.slug-cell {
    font-weight: 700;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.url-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}

.clicks-badge {
    display: inline-block;
    background-color: var(--bg-subtle);
    color: var(--text-main);
    font-weight: 700;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.action-buttons-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Paginação */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Modais de QR Code, Import/Export e Senha */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    padding: 16px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-button);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}

.qr-code-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #ffffff;
    border-radius: var(--radius-md);
    margin: 14px 0;
    border: 1px solid var(--border-button);
}

.qr-code-box svg, 
.qr-code-box img {
    max-width: 200px;
    height: auto;
}

/* Toast de Notificação */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-main);
    color: var(--bg-card);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

/* Spinner e Estados */
.redirect-container {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-button);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading, .no-posts, .error {
    text-align: center;
    padding: 16px;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-button);
}

.hidden {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    body {
        padding: calc(12px + env(safe-area-inset-top, 0px)) 10px calc(16px + env(safe-area-inset-bottom, 0px));
    }
    
    .admin-nav {
        padding: 12px;
    }

    .admin-brand h2 {
        font-size: 15px;
    }

    .action-buttons-cell {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}
