/* =====================================================
   COMPONENTS.CSS — Componentes compartilhados
   Importar em TODAS as páginas, após base.css.
   ===================================================== */

/* ========= FUNDO GRADIENTE ========= */
body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-attachment: fixed;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    background-attachment: fixed;
}

/* ========= FORMAS ANIMADAS DE FUNDO ========= */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    opacity: 0.12;
    z-index: 0;
    animation: float 20s infinite ease-in-out;
    pointer-events: none;
}

.shape-1 {
    width: min(300px, 40vw);
    height: min(300px, 40vw);
    background: rgba(74, 144, 226, 0.4);
    top: 10%;
    left: 5%;
    animation-delay: 0s;
}

.shape-2 {
    width: min(200px, 30vw);
    height: min(200px, 30vw);
    background: rgba(243, 156, 18, 0.4);
    bottom: 10%;
    right: 5%;
    animation-delay: 5s;
}

.shape-3 {
    width: min(250px, 35vw);
    height: min(250px, 35vw);
    background: rgba(46, 204, 113, 0.4);
    top: 60%;
    left: 10%;
    animation-delay: 10s;
}

/* ========= LOADING SCREEN ========= */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: white;
    margin-top: 20px;
    font-size: 1rem;
    opacity: 0.8;
    font-weight: 300;
}

body.loaded .loading {
    opacity: 0;
    pointer-events: none;
}

/* ========= RELÓGIO ========= */
.clock {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    font-weight: 600;
    color: var(--text-color);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    animation: slideInLeft 0.8s ease-out;
    max-width: calc(100% - 120px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all var(--transition-speed) ease;
}

[data-theme="dark"] .clock {
    background: rgba(30, 30, 30, 0.95);
}

.clock i {
    color: var(--primary-color);
    font-size: 0.95rem;
    flex-shrink: 0;
}

[data-theme="dark"] .clock i {
    color: var(--secondary-color);
}

/* ========= BOTÃO DE TEMA ========= */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border: none;
    width: 46px;
    height: 46px;
    border-radius: var(--border-radius);
    cursor: pointer;
    color: var(--text-color);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
    box-shadow: var(--card-shadow);
    z-index: 1000;
    animation: slideInRight 0.8s ease-out;
}

[data-theme="dark"] .theme-toggle {
    background: rgba(30, 30, 30, 0.95);
}

.theme-toggle:hover {
    transform: rotate(15deg);
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(50, 50, 50, 0.95);
}

.theme-toggle i {
    position: absolute;
    transition: opacity var(--transition-speed) ease, transform var(--transition-speed) ease;
}

.theme-toggle .fa-sun  { color: var(--secondary-color); }
.theme-toggle .fa-moon { color: var(--primary-color); opacity: 0; transform: rotate(-90deg); }

[data-theme="dark"] .theme-toggle .fa-sun  { opacity: 0; transform: rotate(90deg); }
[data-theme="dark"] .theme-toggle .fa-moon { opacity: 1; transform: rotate(0deg); }

/* ========= BOTÃO VOLTAR ========= */
.back-button {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    text-decoration: none;
    z-index: 1001;
    animation: slideInLeft 0.8s ease-out;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.1);
}

/* ========= HEADER DE PORTAL (compartilhado entre links e ia-analyzer) ========= */
.portal-header {
    text-align: center;
    color: white;
    width: 100%;
    max-width: 800px;
    margin-bottom: 3rem;
    padding-top: 40px;
}

.header-content {
    padding: 0 20px;
    position: relative;
}

.portal-title {
    font-size: clamp(1.5rem, 3vw, 1.9rem);
    font-weight: 700;
    margin-bottom: 12px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.3px;
    line-height: 1.3;
    animation: fadeInDown 0.8s ease-out;
    position: relative;
    display: inline-block;
    padding-bottom: 15px;
}

.portal-title::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg,
        var(--tertiary-color) 0%,
        var(--tertiary-color) 20%,
        var(--secondary-color) 20%,
        var(--secondary-color) 100%);
    border-radius: 2px;
}

.portal-subtitle {
    font-size: clamp(0.85rem, 1.6vw, 1rem);
    opacity: 0.9;
    font-weight: 400;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

/* ========= CONTAINER PRINCIPAL ========= */
.container {
    width: 100%;
    min-height: 100vh;
    padding: 80px 20px 20px;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto;
    max-width: 1200px;
}

/* ========= CONTEÚDO PRINCIPAL ========= */
.main-content {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 0 0 30px;
}

/* ========= FOOTER ========= */
footer {
    background: var(--primary-color);
    color: white;
    padding: 18px;
    position: relative;
    z-index: 1;
    text-align: center;
    width: 100%;
    max-width: 800px;
    border-radius: var(--border-radius);
    margin-top: 3rem;
    font-size: 0.85rem;
    box-shadow: var(--card-shadow);
    transition: all var(--transition-speed) ease;
}

footer p { margin: 0; line-height: 1.6; }

footer a {
    color: white;
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

footer a:hover { color: var(--secondary-color); }

[data-theme="dark"] footer {
    background: linear-gradient(135deg, #64b5f6, #3a7bc8);
}

/* ========= SCROLLBAR PERSONALIZADA ========= */
@media (min-width: 768px) {
    ::-webkit-scrollbar { width: 10px; }

    ::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 5px;
    }

    ::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 5px;
        transition: background var(--transition-speed) ease;
    }

    ::-webkit-scrollbar-thumb:hover { background: var(--secondary-color); }

    [data-theme="dark"] ::-webkit-scrollbar-track { background: #2d2d2d; }
    [data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--secondary-color); }
    [data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--tertiary-color); }
}

/* ========= FOCO / ACESSIBILIDADE ========= */
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

.back-button:focus-visible {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* ========= TOUCH DEVICES ========= */
@media (hover: none) and (pointer: coarse) {
    .theme-toggle:active { transform: scale(0.95); }
}

/* ========= RESPONSIVIDADE — CONTROLES FIXOS ========= */
@media (max-width: 768px) {
    .container { padding: 70px 15px 15px; }

    .clock {
        top: 15px;
        left: 15px;
        padding: 10px 16px;
        font-size: 0.85rem;
        max-width: calc(100% - 110px);
    }

    .theme-toggle {
        top: 15px;
        right: 15px;
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .back-button { width: 40px; height: 40px; font-size: 1.1rem; }

    footer { margin-top: 2rem; padding: 15px; }
}

@media (max-width: 480px) {
    .container { padding: 65px 12px 12px; }

    .clock {
        top: 12px;
        left: 12px;
        padding: 9px 14px;
        font-size: 0.8rem;
        max-width: calc(100% - 100px);
    }

    .theme-toggle {
        top: 12px;
        right: 12px;
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .back-button { width: 36px; height: 36px; font-size: 1rem; }

    footer { padding: 12px; font-size: 0.8rem; margin-top: 1.5rem; }
}