/* Reset de estilos básicos */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Cores em HSL para harmonia visual */
    --bg-color: hsl(223, 39%, 7%);       /* #0b0f19 */
    --card-bg: hsl(221, 41%, 9%);       /* #0d1421 */
    --card-border: hsl(215, 56%, 24%);   /* #1a365d */
    --input-bg: hsl(221, 44%, 13%);     /* #121b2f */
    --input-border: hsl(224, 64%, 33%); /* #1e3a8a */
    --input-focus: hsl(217, 91%, 60%);  /* #3b82f6 */
    
    /* Gradientes dos Botões */
    --btn-grad-start: hsl(217, 91%, 60%); /* #3b82f6 */
    --btn-grad-end: hsl(220, 96%, 52%);   /* #0f62fc */
    --btn-hover-start: hsl(217, 91%, 68%);/* #60a5fa */
    --btn-hover-end: hsl(224, 76%, 48%);  /* #1d4ed8 */
    --btn-pressed: hsl(220, 96%, 52%);    /* #0f62fc */
    
    --btn-border: hsl(220, 89%, 41%);     /* #0b4ec7 */
    --btn-border-bottom: hsl(220, 91%, 27%); /* #063183 */
    
    /* Cores de Texto */
    --text-primary: #ffffff;
    --text-secondary: hsl(215, 20%, 75%);
    --text-muted: hsl(215, 15%, 50%);
    
    /* Efeitos */
    --glow-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
    --card-glow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 2px rgba(59, 130, 246, 0.15);
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Consolas', 'Fira Code', monospace;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 20px;
}

/* Container do App */
.app-container {
    width: 100%;
    max-width: 480px; /* Alinhado ao tamanho de 460px da janela desktop */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Card Principal (Efeito Vidro/Glow) */
.search-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    width: 100%;
    padding: 30px 40px;
    box-shadow: var(--card-glow);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Logo no topo */
.card-header {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
}

.app-logo {
    height: 55px; /* Tamanho exato do app desktop */
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(59, 130, 246, 0.3));
}

.logo-text-fallback {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 4px;
    background: linear-gradient(135deg, var(--btn-hover-start), var(--btn-grad-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

/* Seção de Busca */
.search-section {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.search-label {
    display: block;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 12px;
}

.search-input-wrapper {
    position: relative;
    margin-bottom: 12px;
}

#search-input,
.search-input-wrapper input {
    width: 100%;
    height: 38px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 19px;
    padding: 8px 20px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#search-input:focus,
.search-input-wrapper input:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

#search-input::placeholder,
.search-input-wrapper input::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

/* Estilo do Botão Primário (3D do Python) */
.btn-primary {
    width: 100%;
    height: 38px;
    background: linear-gradient(to bottom, var(--btn-grad-start), var(--btn-grad-end));
    color: #ffffff;
    border: 1px solid var(--btn-border);
    border-bottom: 3px solid var(--btn-border-bottom);
    border-radius: 19px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    outline: none;
    transition: background 0.2s ease, transform 0.1s ease, border-bottom-width 0.1s ease;
    user-select: none;
}

.btn-primary:hover {
    background: linear-gradient(to bottom, var(--btn-hover-start), var(--btn-hover-end));
}

.btn-primary:active {
    background: var(--btn-pressed);
    border-bottom-width: 1px;
    transform: translateY(2px);
}

.btn-primary.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-primary .icon {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.btn-primary:hover .icon {
    transform: scale(1.1);
}

/* Área de Resultados */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.result-label {
    width: 110px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.row-icon {
    width: 14px;
    height: 14px;
    color: var(--input-focus);
    flex-shrink: 0;
}

.label-text {
    font-size: 13px;
    font-weight: 700;
}

.result-value-wrapper {
    flex-grow: 1;
    display: flex;
    gap: 10px;
    align-items: center;
}

.result-input {
    flex-grow: 1;
    height: 38px;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 19px;
    padding: 0 15px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    width: 100%;
    cursor: default;
    transition: border-color 0.2s ease;
}

.result-input:focus {
    border-color: var(--input-border);
}

.result-input.font-monospace {
    font-family: var(--font-mono);
}

/* Botão de Copiar (3D do Python) */
.btn-copy {
    width: 95px;
    height: 38px;
    flex-shrink: 0;
    background: linear-gradient(to bottom, var(--btn-grad-start), var(--btn-grad-end));
    color: #ffffff;
    border: 1px solid var(--btn-border);
    border-bottom: 3px solid var(--btn-border-bottom);
    border-radius: 19px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    outline: none;
    transition: background 0.2s ease, transform 0.1s ease, border-bottom-width 0.1s ease;
    user-select: none;
}

.btn-copy:hover {
    background: linear-gradient(to bottom, var(--btn-hover-start), var(--btn-hover-end));
}

.btn-copy:active {
    background: var(--btn-pressed);
    border-bottom-width: 1px;
    transform: translateY(2px);
}

.btn-copy .icon {
    width: 15px;
    height: 15px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-left: 4px solid var(--input-focus);
    border-top: 1px solid var(--card-border);
    border-right: 1px solid var(--card-border);
    border-bottom: 1px solid var(--card-border);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    min-width: 250px;
    max-width: 350px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transform: translateX(120%);
    animation: slideIn 0.3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.toast-error {
    border-left-color: hsl(0, 84%, 60%);
}

.toast.toast-warning {
    border-left-color: hsl(36, 100%, 50%);
}

.toast.hide {
    animation: slideOut 0.3s forwards ease-in;
}

/* Animações CSS */
@keyframes slideIn {
    to {
        transform: translateX(0);
    }
}

@keyframes slideOut {
    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

/* Spinner de Carregamento (Loading) */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

/* Efeitos Responsivos */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .search-card {
        padding: 25px 20px;
        border-radius: 12px;
    }
    
    .result-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        background-color: rgba(255, 255, 255, 0.02);
        padding: 12px;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.03);
    }
    
    .result-label {
        width: 100%;
        margin-bottom: 2px;
    }
    
    .result-value-wrapper {
        width: 100%;
    }
    
    #toast-container {
        left: 20px;
        right: 20px;
        bottom: 20px;
    }
    
    .toast {
        min-width: unset;
        width: 100%;
        transform: translateY(120%);
        animation: slideInUp 0.3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    .toast.hide {
        animation: slideOutDown 0.3s forwards ease-in;
    }
}

@keyframes slideInUp {
    to {
        transform: translateY(0);
    }
}

@keyframes slideOutDown {
    to {
        transform: translateY(120%);
        opacity: 0;
    }
}

/* ==========================================
   Estilos de Autenticação Microsoft (MSAL)
   ========================================== */

#user-profile {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    border-top: 1px solid var(--card-border);
    padding-top: 18px;
    margin-top: 25px;
}

.user-profile-widget {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile-widget .avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--btn-grad-start), var(--btn-grad-end));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.user-profile-widget .info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.user-profile-widget .name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-profile-widget .email {
    font-size: 11px;
    color: var(--text-muted);
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    padding: 6px 16px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
}

.btn-logout:active {
    transform: scale(0.95);
}

/* Tela de Login */
.login-card {
    text-align: center;
}

.login-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.login-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 320px;
}

.btn-microsoft {
    background: #2f2f2f;
    border: 1px solid #3f3f3f;
    border-bottom: 3px solid #1f1f1f;
    transition: all 0.2s ease;
}

.btn-microsoft:hover {
    background: #3a3a3a;
    border-color: #4a4a4a;
}

.btn-microsoft:active {
    background: #252525;
    border-bottom-width: 1px;
    transform: translateY(2px);
}

.microsoft-icon {
    width: 16px;
    height: 16px;
    margin-right: 4px;
}

/* Caixa de Erro */
.error-box {
    width: 100%;
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
}

/* Responsivo para Telas Pequenas */
@media (max-width: 400px) {
    .user-profile-widget .info {
        display: none;
    }
}

/* ==========================================
   Abas de Navegação (Menu Admin)
   ========================================== */
.nav-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 15px;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    padding: 8px 18px;
    border-radius: 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    user-select: none;
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    color: var(--text-primary);
    background-color: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Formulário de Cadastro Extra */
#registration-section button[type="submit"] {
    margin-top: 10px;
}
