/* * ================================================================================================
 * [SECTOR 18] PROFILE ARCHITECTURE MOD (CONSOLIDATED & ISOLATED)
 * ================================================================================================
 */

/* 1. MAIN CONTAINER */
.profile-container {
    max-width: 500px !important;
    margin: 0 auto;
    padding: 0 1.5rem 2rem 1.5rem; /* Sem padding-top para conteúdo visível até ao topo */
    position: relative;
    z-index: 120;
}

.profile-header {
    display: none !important;
}

.profile-avatar {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 20px var(--accent);
    flex-shrink: 0;
    margin-bottom: 0.9rem;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    transform: translateY(10px);
}

/* 4. INFO WRAPPER */
.profile-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* 5. NAME (H1) */
.profile-info h1 {
    margin: 0 0 1rem 0;
    margin-bottom: 1rem;
    font-size: 1.6rem;
    color: var(--text);
    font-weight: 800;
    text-align: center;
    stroke: var(--accent);
}

/* 6. BIO */
.profile-info .bio {
    margin: 0 0 0.57rem 0;
    opacity: 0.7;
    font-size: 0.95rem;
    text-align: center;
    max-width: 100%;
    line-height: 1.4;
}

/* 7. STATS CONTAINER */
.profile-stats-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 10px 0 18px 0;
    width: 100%;
}

/* 8. INDIVIDUAL METRICS */
.stat-metric {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    color: var(--accent);
    font-weight: 500;
}

.stat-val {
    font-weight: 800;
    font-size: 1.1rem;
}

.stat-label {
    opacity: 0.7;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text);
}

/* 9. ACTION BUTTONS */
.action-btn {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 8px 24px;
    border-radius: 50px;
    cursor: pointer;
    transition: 0.3s;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    margin-top: 5px;
}

.action-btn:hover {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 15px var(--accent);
}

.action-btn.following {
    background: var(--accent);
    color: #000;
}

/* 10. PROFILE STREAM (Feed Area) */
#p-stream {
    perspective: 1000px;
    padding: 1rem 1.3rem 5rem 1.3rem;
    position: relative;
    z-index: 1;
    min-height: 200px;
    overflow-x: hidden;
}

/* Contacts Mode - No Header */
#view-profile .profile-header[style*="display: none"] + #p-stream,
#view-profile:has(.profile-header[style*="display: none"]) #p-stream {
    padding-top: 0;
}

/* 11. ISOLATED FEED CARDS (Cloned from article-row) */
.profile-signal-unit {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--card-border-color);
    border-radius: var(--radius-lg);
    opacity: 1;
    transform-style: preserve-3d;
    backface-visibility: hidden;

    /* Shadow - slightly lighter than article-row */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);

    /* Physics Defaults */
    transform: scale(0.95);
    will-change: transform, box-shadow, opacity;
}

/* Active focus removed - all articles same style */

.p-signal-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding-right: 20px;
}

.p-signal-title {
    font-size: 1.0rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    stroke: var(--accent);
}

.p-signal-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .8rem;
    color: #888;
    transition: color 0.2s ease;
}

.meta-left {
    display: flex;
    align-items: center;
}

.meta-read-time {
    font-weight: bold;
}

.meta-separator {
    margin: 0 5px;
}

.article-excerpt {
    display: none;
    margin-top: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text);
    opacity: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease, margin 0.3s ease, opacity 0.3s ease;
}

/* Profile Read Button - Same style as Home */
.profile-read-btn {
    display: none;
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    opacity: 1;
}

.profile-read-btn.visible {
    display: inline-block;
}

/* 12. RESPONSIVE ADJUSTMENTS */
@media(max-width: 600px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
        gap: 0.8rem;
        padding: 0.8rem 1rem;
        height: auto !important;
    }
    .profile-stats-container {
        justify-content: center;
    }
}

/* ============================================
   MINIMAL PROFILE MODE (Like Preview Miniature)
   No card/glass background, just content
   ============================================ */
body.floating-profile-header .profile-header {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
    min-height: auto !important;
    padding: 20px 0 !important;
    margin-bottom: 0 !important;
}

body.floating-profile-header .profile-header .profile-avatar {
    width: 70px !important;
    height: 70px !important;
    margin-bottom: 12px !important;
    transform: none !important;
    box-shadow: none !important;
    background: var(--glass-bg) !important;
    border: 2px solid var(--accent) !important;
}

body.floating-profile-header .profile-header .profile-info h1 {
    font-size: 1.1rem !important;
    margin-bottom: 4px !important;
}

body.floating-profile-header .profile-header .profile-info .bio {
    font-size: 0.75rem !important;
    margin-bottom: 12px !important;
    opacity: 0.5 !important;
}

body.floating-profile-header .profile-header .profile-stats-container {
    gap: 30px !important;
    margin-top: 8px !important;
}

body.floating-profile-header .profile-header .profile-stats-container .stat-val {
    font-size: 1.1rem !important;
    color: var(--accent) !important;
}

body.floating-profile-header .profile-header .profile-stats-container .stat-label {
    font-size: 0.6rem !important;
    text-transform: uppercase !important;
    opacity: 0.4 !important;
}

body.floating-profile-header .profile-header #follow-btn {
    display: none !important;
}

/* Adjust profile container - keep same level as normal mode */
body.floating-profile-header .profile-container {
    padding-top: 2rem !important;
}

body.floating-profile-header #view-profile .stream-container {
    margin-top: 0 !important;
}

/* ============================================
   CONTACT CARDS - Profile Section
   ============================================ */

/* Contact Header with Avatar */
.contact-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.contact-avatar-mini {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: #000;
    text-transform: uppercase;
}

.contact-name {
    width: 100%;
    font-size: 1rem !important;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    text-align: center !important;
    display: block;
}

.contact-meta {
    padding-left: 52px; /* Align with name (avatar width + gap) */
}

.contact-phone {
    font-size: 0.8rem;
    color: #888;
    opacity: 0.8;
}

/* Expanded Actions Panel - hidden by default, shown via JS */
.contact-actions-expanded {
    display: none;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
    padding: 12px 0 4px 0;
    margin-top: 12px;
    pointer-events: none;
}

/* Action Buttons */
.contact-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    max-width: 100px;
}

.contact-action-btn svg {
    width: 22px;
    height: 22px;
    stroke: var(--accent);
}

.contact-action-btn span {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.contact-action-btn:hover {
    background: rgba(var(--accent-rgb), 0.1);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.contact-action-btn:active {
    transform: translateY(0);
}

/* ============================================
   CONTACT CARD - Complete Override
   ============================================ */

/* Reset do card base para contactos - SEM override do transform para manter animação */
.profile-signal-unit.contact-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 1.2rem 1rem !important;
    min-height: auto !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Container do conteúdo - centrado */
.profile-signal-unit.contact-card .p-signal-content,
.profile-signal-unit.contact-card .contact-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: auto !important;
    padding: 0 !important;
    padding-right: 0 !important;
    gap: 0 !important;
    pointer-events: auto !important;
}

/* Nome do contacto - centrado com padding */
.profile-signal-unit.contact-card .contact-name,
.profile-signal-unit.contact-card .p-signal-title.contact-name,
.profile-signal-unit.contact-card h3.contact-name {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    width: 100% !important;
    height: auto !important;
    min-height: 1.3em !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: var(--text) !important;
}

/* ============================================
   CONTACT CARD - Estado Expandido
   ============================================ */
.profile-signal-unit.contact-card[data-expanded="true"] {
    background: rgba(255, 255, 255, 0.025) !important;
    padding: 0.9rem 1rem !important;
    min-height: auto !important;
}

.profile-signal-unit.contact-card[data-expanded="true"] .p-signal-content,
.profile-signal-unit.contact-card[data-expanded="true"] .contact-content {
    height: auto !important;
}

.profile-signal-unit.contact-card[data-expanded="true"] .contact-name,
.profile-signal-unit.contact-card[data-expanded="true"] .p-signal-title.contact-name,
.profile-signal-unit.contact-card[data-expanded="true"] h3.contact-name {
    height: auto !important;
    line-height: 1.4 !important;
    padding: 0.3rem 0 !important;
}

.profile-signal-unit.contact-card[data-expanded="true"] .contact-actions-expanded {
    display: flex !important;
    pointer-events: auto !important;
}

/* ============================================
   GROUP CARDS - Estilo diferente para grupos
   ============================================ */
.profile-signal-unit.contact-card.group-card {
    border: 2px solid rgba(var(--accent-rgb), 0.35) !important;
    background: rgba(var(--accent-rgb), 0.05) !important;
}

.profile-signal-unit.contact-card.group-card .group-name {
    color: var(--accent) !important;
}

/* ============================================
   VIEW-CONTACTS - Secção independente
   ============================================ */
#view-contacts {
    min-height: 100vh;
    height: auto !important;
    display: none;
    padding-bottom: 120px;
    overflow-x: hidden;
}

#view-contacts.active-view {
    display: block !important;
}

#contacts-stream {
    padding: 1rem 1.3rem 1.3rem 1.3rem;
    padding-bottom: calc(100vh - 200px);
    position: relative;
    z-index: 1;
    min-height: 200px;
}

/* Contact Card na view-contacts */
#contacts-stream .contact-card {
    position: relative;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 1rem 0.8rem !important;
    margin-bottom: 1.2rem;
    margin-left: auto;
    margin-right: auto;
    max-width: 280px;
    width: 75%;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--card-border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
    cursor: pointer;
    /* Animação controlada por JavaScript */
    will-change: transform, opacity;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

/* Nome do contacto */
#contacts-stream .contact-card .contact-name {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: var(--text) !important;
}

/* Ações expandidas */
#contacts-stream .contact-card .contact-actions-expanded {
    display: none;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
    padding: 12px 0 4px 0;
    margin-top: 12px;
    width: 100%;
}

#contacts-stream .contact-card[data-expanded="true"] {
    background: rgba(255, 255, 255, 0.025) !important;
}

#contacts-stream .contact-card[data-expanded="true"] .contact-actions-expanded {
    display: flex !important;
}

/* ============================================
   PROFILE OVERLAY - FULLSCREEN (outside main)
   ============================================ */

/* Profile Overlay - escondido por defeito */
#profile-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998; /* Abaixo do settings (9999) mas acima de tudo o resto */
    background: var(--bg);
    overflow-y: scroll;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    display: none;
}

/* Profile Overlay visível */
#profile-overlay.active {
    display: block;
}

/* Wrapper dos cards - FULLSCREEN com padding para safe areas */
#profile-overlay .profile-cards-wrapper {
    display: grid;
    gap: 2px;
    max-width: 335px;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top, 20px) + 120px) 1.5rem calc(env(safe-area-inset-bottom, 20px) + 100px) 1.5rem;
    min-height: 100%;
}

/* Cards no profile overlay - 89% da escala */
#profile-overlay .ai-prompt-card {
    transform: scale(0.89);
    transform-origin: center top;
}

/* ============================================
   FALLBACK - Antiga estrutura dentro de main
   ============================================ */

/* View base - escondida por defeito */
#view-profile {
    display: none;
    background: transparent;
}

/* View inativa */
#view-profile:not(.active-view) {
    position: fixed;
    inset: 0;
    visibility: hidden;
    z-index: -1;
}

/* View ativa - FULLSCREEN ABSOLUTO */
#view-profile.active-view {
    display: block;
    position: fixed;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Wrapper dos cards - FULLSCREEN */
.profile-cards-wrapper {
    display: grid;
    gap: 24px;
    max-width: 440px;
    margin: 0 auto;
    padding: 0 1.5rem 120px 1.5rem;
}

/* Cards */
.profile-cards-wrapper .ai-prompt-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 28px;
    padding: 20px;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.25);
}

/* ===========================================
   FALLBACK - Classes antigas (compatibilidade)
   =========================================== */
.ai-studio-container,
.ai-prompt-cards {
    display: grid;
    gap: 24px;
    max-width: 440px;
    margin: 0 auto;
    padding: 0 1.5rem 120px 1.5rem;
}

/* Individual Card */
.ai-prompt-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 28px;
    padding: 20px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.25), 0 3px 10px rgba(0, 0, 0, 0.15);
}

/* Full width card */
.ai-prompt-card-full {
    grid-column: span 1;
}

/* Card Header */
.ai-prompt-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: -6px;
    margin-bottom: 2px;
}

.ai-prompt-card-icon {
    width: 58px;
    height: 58px;
    min-width: 58px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.ai-prompt-card-icon svg {
    width: 30px;
    height: 30px;
}

.ai-prompt-card-title {
    flex: 1;
    min-width: 0;
}

.ai-prompt-card-title h4 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.2;
}

.ai-prompt-card-title span {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    display: block;
    margin-top: 5px;
}

/* ============================================
   NOVA TEXTAREA - Simples e Funcional
   ============================================ */
.ai-prompt-textarea {
    display: block;
    width: 100%;
    /* 7 linhas: (14px * 1.5 line-height * 7) + padding (28px) = 175px */
    min-height: 175px;
    padding: 14px;
    margin: 0;

    /* Cores */
    background: rgba(0, 0, 0, 0.1) !important;
    border: none !important;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.75) !important;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5) !important;

    /* Texto */
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;

    /* Auto-expand essencial */
    resize: none;
    overflow: hidden;
    box-sizing: border-box;

    /* Remove estilos nativos */
    outline: none;
    -webkit-appearance: none;
}

.ai-prompt-textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.ai-prompt-textarea:focus {
    background: rgba(255, 255, 255, 0.05) !important;
    outline: 2px solid rgba(255, 255, 255, 0.5) !important;
    outline-offset: -1px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6) !important;
    color: #fff !important;
}

/* ===== LOCKED STATE - Textareas bloqueadas ===== */
#profile-overlay.profile-locked .ai-prompt-textarea {
    cursor: default;
    caret-color: transparent;
}

/* Actions */
.ai-studio-container .ai-studio-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    padding-top: 16px;
}

.ai-studio-container .ai-studio-reset-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-studio-container .ai-studio-reset-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
}

.ai-studio-container .ai-studio-reset-btn:active {
    transform: scale(0.98);
}

.ai-studio-container .ai-studio-save-btn {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ai-studio-container .ai-studio-save-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
}

.ai-studio-container .ai-studio-save-btn:active {
    transform: scale(0.98);
}

.ai-studio-container .ai-studio-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Status Message */
.ai-studio-container .ai-studio-status {
    text-align: center;
    padding: 12px;
    margin-top: 12px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 500;
    display: none;
}

.ai-studio-container .ai-studio-status.success {
    display: block;
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.ai-studio-container .ai-studio-status.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.ai-studio-container .ai-studio-status.loading {
    display: block;
    background: rgba(139, 92, 246, 0.1);
    color: #8B5CF6;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* Responsive - Adjustments for Small Screens */
@media (max-width: 420px) {
    .ai-studio-container {
        padding: 1rem;
    }

    .ai-studio-header {
        padding: 18px;
    }

    .ai-studio-header-icon {
        width: 52px;
        height: 52px;
        min-width: 52px;
        border-radius: 14px;
    }

    .ai-studio-header-icon svg {
        width: 26px;
        height: 26px;
    }

    .ai-studio-header-text h2 {
        font-size: 1.2rem;
    }

    .ai-prompt-card {
        padding: 22px;
        border-radius: 22px;
    }

    .ai-prompt-card-icon {
        width: 52px;
        height: 52px;
        min-width: 52px;
    }

    .ai-prompt-card-icon svg {
        width: 26px;
        height: 26px;
    }

    #view-profile .ai-studio-container .ai-prompt-textarea {
        /* 7 linhas: (16px * 1.5 line-height * 7) + padding (32px) = 200px */
        min-height: 200px;
        padding: 16px 18px;
        font-size: 16px; /* Keep 16px to prevent iOS zoom */
    }

    .ai-studio-container .ai-studio-actions {
        flex-direction: column;
    }

    .ai-studio-container .ai-studio-reset-btn,
    .ai-studio-container .ai-studio-save-btn {
        flex: none;
        width: 100%;
    }
}











/* AI Studio Inputs - Cursor Nativo */
#ai-sys-prompt,
#ai-user-prompt {
    caret-color: var(--accent) !important; /* Cor do cursor igual ao tema */
    cursor: text;
}

/* Garante que o texto não fica escondido atrás de overlays antigos */
.ai-prompt-textarea {
    position: relative;
    z-index: 2; 
}