/* ========================================= */
/* NOVOS COMPONENTES E MELHORIAS            */
/* ========================================= */

/* Estilos para descrição de autenticação */
.auth-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    line-height: 1.6;
}

/* Grupos de input melhorados */
.input-group {
    position: relative;
    margin-bottom: var(--space-lg);
}

.input-group input {
    width: 100%;
    padding: var(--space-lg);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    transition: all var(--transition-normal);
    background: var(--bg-secondary);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

.input-group input:focus + .floating-label,
.input-group input:not(:placeholder-shown) + .floating-label {
    transform: translateY(-1.5rem) scale(0.875);
    color: var(--primary-color);
}

/* Botões primários e secundários */
.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-white);
    border: none;
}

.secondary-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-light);
}

.danger-btn {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: var(--text-white);
    border: none;
}

.danger-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.google-btn {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border-light);
}

.google-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-medium);
}

/* Grid de componentes */
.component-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--space-sm);
}

/* Botões de ação */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Canvas overlay e controles */
.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    color: var(--primary-color);
}

.loading-spinner i {
    font-size: 2rem;
}

.canvas-controls {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    z-index: 10;
}

.canvas-control-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
}

.canvas-control-btn:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
}

/* Properties panel melhorado */
.properties-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.property-group {
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
}

.property-group h4 {
    margin-bottom: var(--space-md);
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.property-help {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: var(--space-xs);
    display: block;
}

/* Modal melhorado */
.modal-body {
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    margin-top: var(--space-xl);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-light);
}

.section-divider {
    margin: var(--space-xl) 0;
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-light), transparent);
}

.highlight-value {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.125rem;
}

.diagram-container {
    text-align: center;
    background: var(--bg-tertiary);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

/* Global loading overlay */
.global-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9), rgba(118, 75, 162, 0.9));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(10px);
}

.loading-content {
    text-align: center;
    color: var(--text-white);
}

.loading-content .loading-spinner {
    color: var(--text-white);
    font-size: 1.125rem;
}

.loading-content .loading-spinner i {
    font-size: 3rem;
    margin-bottom: var(--space-lg);
}

/* Toast notifications */
#toast-container {
    position: fixed;
    top: var(--space-xl);
    right: var(--space-xl);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-width: 400px;
    width: 100%;
}

.toast {
    padding: var(--space-lg);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    animation: slideInRight 0.3s ease-out;
}

.toast-success {
    border-left-color: var(--success-color);
}

.toast-error {
    border-left-color: var(--danger-color);
}

.toast-warning {
    border-left-color: var(--accent-color);
}

.toast i {
    font-size: 1.125rem;
    flex-shrink: 0;
}

.toast-success i {
    color: var(--success-color);
}

.toast-error i {
    color: var(--danger-color);
}

.toast-warning i {
    color: var(--accent-color);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    margin-left: auto;
    transition: all var(--transition-fast);
}

.toast-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.toast-fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Melhorias nos formulários */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: var(--space-lg);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-normal);
    background: var(--bg-secondary);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input.is-invalid {
    border-color: var(--danger-color);
}

.form-input.is-valid {
    border-color: var(--success-color);
}

.form-error {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: var(--space-xs);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Estilos para listas de projetos */
.project-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.project-item {
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.project-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.project-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.project-name {
    font-weight: 600;
    color: var(--text-primary);
}

.project-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.project-actions {
    display: flex;
    gap: var(--space-xs);
}

.project-action-btn {
    padding: var(--space-xs) var(--space-sm);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.75rem;
}

.project-action-btn.load {
    background: var(--primary-color);
    color: var(--text-white);
}

.project-action-btn.delete {
    background: var(--danger-color);
    color: var(--text-white);
}

.project-action-btn:hover {
    transform: scale(1.05);
}

/* Melhorias na responsividade para toast */
@media (max-width: 768px) {
    #toast-container {
        top: var(--space-md);
        right: var(--space-md);
        left: var(--space-md);
        max-width: none;
    }
    
    .toast {
        padding: var(--space-md);
        font-size: 0.875rem;
    }
}

/* Estilos para estado vazio */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Indicadores de progresso */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin: var(--space-md) 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: var(--radius-lg);
    transition: width var(--transition-normal);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Melhorias na acessibilidade */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus trap para modais */
.modal[aria-hidden="false"] {
    display: block !important;
}

/* Animações de entrada */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-in-up {
    animation: slideInUp 0.3s ease-out;
}

.slide-in-down {
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Estilos para elementos ativos/selecionados */
.is-active {
    background: var(--primary-color) !important;
    color: var(--text-white) !important;
    border-color: var(--primary-color) !important;
}

.is-selected {
    border-color: var(--primary-color) !important;
    background: rgba(37, 99, 235, 0.1) !important;
}

/* Melhorias no contraste para modo escuro */
@media (prefers-color-scheme: dark) {
    .auth-container {
        background: var(--bg-primary);
        border: 1px solid var(--border-light);
    }
    
    .canvas-control-btn {
        background: var(--bg-primary);
        border-color: var(--border-light);
    }
    
    .toast {
        background: var(--bg-primary);
        border: 1px solid var(--border-light);
    }
}

/* Otimizações de performance */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Layout improvements para dispositivos pequenos */
@media (max-width: 480px) {
    :root {
        --space-xs: 0.125rem;
        --space-sm: 0.375rem;
        --space-md: 0.75rem;
        --space-lg: 1rem;
        --space-xl: 1.25rem;
        --space-2xl: 2rem;
    }
    
    .component-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .project-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
    
    .project-actions {
        align-self: stretch;
        justify-content: space-between;
    }
}/* ========================================= */
/* RESET E CONFIGURAÇÕES GLOBAIS            */
/* ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* Cores principais */
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    
    /* Cores de fundo */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-dark: #0f172a;
    
    /* Cores de texto */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-white: #ffffff;
    
    /* Cores de borda */
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    --border-dark: #475569;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Raios de borda */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Espaçamentos */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Transições */
    --transition-fast: 0.15s ease-in-out;
    --transition-normal: 0.3s ease-in-out;
    --transition-slow: 0.5s ease-in-out;
}

body {
    height: 100vh;
    /* overflow: hidden; */ /* <-- MUDANÇA 1: REMOVIDA A LINHA QUE IMPEDIA A ROLAGEM */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg-secondary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    height: 100%;
}

/* ========================================= */
/* ESTILOS DA TELA DE LOGIN MELHORADOS      */
/* ========================================= */
#login-area {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: var(--space-lg);
    position: relative;
}

#login-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="white" stroke-width="0.5" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    pointer-events: none;
}

.auth-container {
    background: var(--bg-primary);
    padding: var(--space-2xl);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    text-align: center;
    position: relative;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideIn 0.6s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-container h2 {
    margin-bottom: var(--space-xl);
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.auth-container input {
    width: 100%;
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    transition: all var(--transition-normal);
    background: var(--bg-secondary);
}

.auth-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

.auth-container button {
    width: 100%;
    padding: var(--space-lg);
    border: none;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-white);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.auth-container button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.auth-container button:hover::before {
    left: 100%;
}

.auth-container button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.auth-container button:active {
    transform: translateY(0);
}

#google-login-button {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-md);
    font-weight: 500;
}

#google-login-button:hover {
    background: var(--bg-secondary);
    border-color: var(--border-medium);
}

#google-login-button img {
    width: 20px;
    height: 20px;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    margin: var(--space-xl) 0;
    font-size: 0.875rem;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-light);
}

.divider:not(:empty)::before {
    margin-right: var(--space-md);
}

.divider:not(:empty)::after {
    margin-left: var(--space-md);
}

.forgot-password {
    display: block;
    text-align: right;
    margin-bottom: var(--space-xl);
    font-size: 0.875rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.forgot-password:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.auth-switch {
    margin-top: var(--space-xl);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.auth-switch a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

#auth-error {
    color: var(--danger-color);
    margin-top: var(--space-md);
    font-weight: 600;
    padding: var(--space-md);
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--danger-color);
}

/* ========================================= */
/* ESTILOS DA APLICAÇÃO PRINCIPAL           */
/* ========================================= */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* <-- MUDANÇA 2: GARANTE QUE O CONTAINER OCUPE PELO MENOS A ALTURA DA TELA, MAS PODE CRESCER */
    background: var(--bg-primary);
    /* overflow: hidden; */ /* <-- MUDANÇA 3: REMOVIDA A LINHA QUE IMPEDIA A ROLAGEM */
}

/* CABEÇALHO MELHORADO */
.header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: var(--text-white);
    border-bottom: 3px solid var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) var(--space-xl);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
    z-index: 1000;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    letter-spacing: -0.025em;
}

.logo i {
    color: var(--accent-color);
    font-size: 1.5rem;
}

#user-info {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

#user-info p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-white);
    opacity: 0.9;
}

#user-info #logout-button,
#user-info #manage-subscription-button {
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.875rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-white);
    font-weight: 500;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
}

#user-info #logout-button:hover,
#user-info #manage-subscription-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* BARRA DE FERRAMENTAS MELHORADA */
.toolbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    gap: var(--space-lg);
    align-items: center;
    flex-wrap: nowrap; /* MUDANÇA: Impede que os itens quebrem para a próxima linha */
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    overflow-x: auto; /* GARANTIA: Adiciona rolagem horizontal quando necessário */
    -webkit-overflow-scrolling: touch;
}

.tool-group {
    display: flex;
    gap: var(--space-xs);
    background: var(--bg-secondary);
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.tool-btn {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-light);
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.tool-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.tool-btn.active {
    background: var(--primary-color);
    color: var(--text-white);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.tool-btn i {
    font-size: 0.875rem;
}

/* CONTEÚDO PRINCIPAL */
.main-content {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    overflow: hidden;
    min-height: 0;
}



/* SIDEBARS MELHORADAS */
.sidebar, .properties-panel {
    background: var(--bg-primary);
    overflow-y: auto;
    flex-shrink: 0;
    border: 1px solid var(--border-light);
}

.sidebar {
    width: 280px;
    border-right: 1px solid var(--border-light);
    padding: var(--space-lg);
}

.properties-panel {
    width: 320px;
    border-left: 1px solid var(--border-light);
    padding: var(--space-lg);
}

.sidebar-section {
    margin-bottom: var(--space-xl);
}

.sidebar-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--border-light);
}

.component-item {
    width: 100%;
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.component-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.component-item i {
    color: var(--primary-color);
    font-size: 1rem;
}

/* CANVAS CONTAINER */
.canvas-container {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7f8fa;
    overflow: hidden;
    border: 1px solid var(--border-light);
    margin: var(--space-sm);
    border-radius: 4px;
}

#canvas {
    background: #ffffff;
    border-radius: 0;
    box-shadow: none;
    touch-action: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block; 
}

/* PROPRIEDADES */
.properties-panel h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--border-light);
}

.property-item {
    margin-bottom: var(--space-lg);
}

.property-item label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.property-item input,
.property-item select {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all var(--transition-normal);
}

.property-item input:focus,
.property-item select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.manual-wires-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

.manual-wires-grid .property-item {
    margin-bottom: 0;
}

/* MODAL MELHORADO */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    overflow: auto;
    padding: var(--space-xl);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-primary);
    margin: 5% auto;
    padding: var(--space-2xl);
    border-radius: var(--radius-xl);
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--border-light);
}

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.close-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* TABELAS */
.modal table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-md);
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.modal th, .modal td {
    border: 1px solid var(--border-light);
    padding: var(--space-md);
    text-align: left;
    font-size: 0.875rem;
}

.modal th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.modal tr:hover {
    background: var(--bg-secondary);
}

/* ÁREA DA LEGENDA */
.legend-area {
    flex-shrink: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
    max-height: 250px;
    overflow-y: auto;
    padding: var(--space-lg);
}

/* BARRA DE STATUS */
.status-bar {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    padding: var(--space-sm) var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.status-bar span {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

/* ========================================= */
/* PÁGINA DE ASSINATURA MELHORADA           */
/* ========================================= */
#subscribe-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: var(--space-xl);
}

.subscribe-header {
    width: 100%;
    max-width: 1200px;
    padding: var(--space-lg) 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-white);
}

.user-context {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 500;
}

.logout-link {
    color: var(--text-white);
    text-decoration: none;
    font-weight: 600;
    padding: var(--space-sm) var(--space-lg);
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
}

.logout-link:hover {
    background: rgba(255, 255, 255, 0.2);
    text-decoration: none;
}

.subscription-card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 480px;
    padding: var(--space-2xl);
    text-align: center;
    border-top: 6px solid var(--primary-color);
    animation: fadeInUp 0.6s ease-out;
    backdrop-filter: blur(10px);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-header .card-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: var(--space-lg);
}

.card-header h2 {
    font-size: 2rem;
    margin: 0 0 var(--space-md) 0;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.025em;
}

.card-header p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

.feature-list {
    margin: var(--space-2xl) 0;
    text-align: left;
}

.feature-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.feature-list li {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
}

.feature-list li:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.feature-list li i {
    color: var(--success-color);
    font-size: 1.25rem;
    flex-shrink: 0;
}

.pricing-area {
    margin: var(--space-2xl) 0;
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: var(--space-sm);
}

.price {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.05em;
}

.period {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.upgrade-btn {
    width: 100%;
    padding: var(--space-lg);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-white);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-md);
    position: relative;
    overflow: hidden;
}

.upgrade-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.upgrade-btn:hover::before {
    left: 100%;
}

.upgrade-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
}

.card-footer {
    margin-top: var(--space-2xl);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.card-footer p {
    margin: var(--space-sm) 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-sm);
}

.payment-logos {
    margin-top: var(--space-lg);
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    color: var(--text-muted);
}

/* ========================================= */
/* RESPONSIVIDADE MOBILE MELHORADA          */
/* ========================================= */
@media (max-width: 768px) {
    .app-container {
        /* Garante que o app não ultrapasse a altura da tela no modo mobile */
        height: 100vh;
        max-height: 100vh;
    }

    .header {
        padding: var(--space-md);
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .logo {
        font-size: 1rem;
    }

    #user-info {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    #user-info p {
        font-size: 0.75rem;
    }

    .toolbar {
        padding: var(--space-sm);
        gap: var(--space-sm);
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tool-group {
        flex-shrink: 0;
        gap: var(--space-xs);
    }

    .tool-btn {
        padding: var(--space-sm);
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Principal mudança: empilha os painéis verticalmente */
    .main-content {
        flex-direction: column;
    }

    /* --- REGRAS CORRIGIDAS PARA A BARRA LATERAL ESQUERDA --- */
    .sidebar {
        width: 100%;
        height: auto; /* Altura automática */
        max-height: 45vh; /* Define uma altura máxima antes de rolar */
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        display: block; /* Garante que as seções fiquem uma abaixo da outra */
        overflow-x: hidden; /* Remove a rolagem horizontal indesejada */
        overflow-y: auto; /* Adiciona rolagem vertical interna se necessário */
        padding: var(--space-md);
        background: var(--bg-secondary);
    }

    .sidebar-section {
        white-space: normal; /* Permite que o texto quebre a linha normalmente */
        margin-bottom: var(--space-lg);
    }

    .sidebar-section h3 {
        margin-bottom: var(--space-sm);
        font-size: 0.875rem;
        border-bottom: none;
        padding-bottom: 0;
    }
    
    /* Organiza os botões em uma grade adaptável */
    .component-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: var(--space-sm);
    }

    .component-item {
        width: 100%;
        margin: 0;
        padding: var(--space-sm);
        font-size: 0.75rem;
    }

    /* --- FIM DAS REGRAS CORRIGIDAS --- */

    .canvas-container {
        flex-grow: 1; /* Faz o canvas ocupar o espaço restante */
        min-height: 200px;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .properties-panel {
        width: 100%;
        max-height: 35vh; /* Altura máxima para o painel de propriedades */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-left: none;
        border-top: 1px solid var(--border-light);
        flex-shrink: 0;
        background: var(--bg-primary);
    }

    .properties-panel h3 {
        font-size: 1rem;
        margin-bottom: var(--space-md);
    }

    .legend-area {
        display: none;
    }

    .status-bar {
        padding: var(--space-sm);
        font-size: 0.6rem;
        flex-wrap: wrap;
        gap: var(--space-xs);
    }

    .status-bar span {
        padding: var(--space-xs);
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        text-align: center;
        gap: var(--space-md);
    }

    .toolbar {
        justify-content: flex-start;
    }

    .tool-btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.7rem;
    }

    .tool-btn i {
        font-size: 0.75rem;
    }

    .sidebar {
        padding: var(--space-sm);
        gap: var(--space-md);
    }

    .component-item {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.7rem;
    }

    .properties-panel {
        padding: var(--space-md);
    }

    .property-item input,
    .property-item select {
        padding: var(--space-sm);
        font-size: 0.875rem;
    }
}

/* ========================================= */
/* ANIMAÇÕES E EFEITOS ESPECIAIS            */
/* ========================================= */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -30px, 0);
    }
    70% {
        transform: translate3d(0, -15px, 0);
    }
    90% {
        transform: translate3d(0, -4px, 0);
    }
}

.loading {
    animation: pulse 2s infinite;
}

.bounce {
    animation: bounce 1s;
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) var(--bg-secondary);
}

/* ========================================= */
/* UTILITÁRIOS E CLASSES AUXILIARES         */
/* ========================================= */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.font-medium {
    font-weight: 500;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-lg {
    font-size: 1.125rem;
}

.text-xl {
    font-size: 1.25rem;
}

.text-2xl {
    font-size: 1.5rem;
}

.mt-auto {
    margin-top: auto;
}

.mb-auto {
    margin-bottom: auto;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-row {
    flex-direction: row;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

.gap-lg {
    gap: var(--space-lg);
}

.rounded {
    border-radius: var(--radius-md);
}

.rounded-lg {
    border-radius: var(--radius-lg);
}

.shadow {
    box-shadow: var(--shadow-md);
}

.shadow-lg {
    box-shadow: var(--shadow-lg);
}

.bg-primary {
    background-color: var(--bg-primary);
}

.bg-secondary {
    background-color: var(--bg-secondary);
}

.text-primary {
    color: var(--text-primary);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-muted {
    color: var(--text-muted);
}

.border {
    border: 1px solid var(--border-light);
}

.border-primary {
    border-color: var(--primary-color);
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.transition {
    transition: all var(--transition-normal);
}

.transition-fast {
    transition: all var(--transition-fast);
}

/* ========================================= */
/* MODO ESCURO (DARK MODE)                  */
/* ========================================= */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1e293b;
        --bg-secondary: #0f172a;
        --bg-tertiary: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
        --border-light: #334155;
        --border-medium: #475569;
        --border-dark: #64748b;
    }
}

[data-theme="dark"] {
    --bg-primary: #1e293b;
    --bg-secondary: #0f172a;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-light: #334155;
    --border-medium: #475569;
    --border-dark: #64748b;
}

/* ========================================= */
/* MELHORIAS NA LEGENDA E TABELAS           */
/* ========================================= */
.legend-table-container {
    margin-top: var(--space-md);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.legend-table-container h3 {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-white);
    margin: 0;
    padding: var(--space-lg);
    font-size: 1.125rem;
    font-weight: 600;
}

.wiring-legend-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.wiring-legend-table th {
    background: var(--bg-tertiary);
    padding: var(--space-md);
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-medium);
}

.wiring-legend-table td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    line-height: 1.4;
}

.wiring-legend-table tr:hover {
    background: var(--bg-secondary);
}

.legend-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-lg);
    color: var(--text-white);
    font-weight: 600;
    text-align: center;
    min-width: 32px;
    height: 32px;
    font-size: 0.875rem;
}

.legend-badge.trunk {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
}

.legend-badge.circuit {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.legend-wiring, .legend-gauge {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    background: var(--bg-secondary);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    line-height: 1.3;
    border: 1px solid var(--border-light);
}

.legend-gauge {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.legend-row.legend-t {
    background: linear-gradient(90deg, rgba(142, 68, 173, 0.05), transparent);
    border-left: 4px solid var(--primary-color);
}

.legend-summary {
    background: var(--bg-secondary);
    padding: var(--space-lg);
    border-top: 1px solid var(--border-light);
    font-size: 0.875rem;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.legend-summary p {
    margin: var(--space-sm) 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legend-summary p strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* ========================================= */
/* PRINTS E ACESSIBILIDADE                  */
/* ========================================= */
@media print {
    .header, .toolbar, .sidebar, .properties-panel, .status-bar {
        display: none !important;
    }
    
    .main-content {
        flex-direction: row;
    }
    
    .canvas-container {
        margin: 0;
        border: none;
        box-shadow: none;
    }
    
    body {
        background: white;
        color: black;
    }
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    /* overflow: hidden; */ /* <-- MUDANÇA 4: REMOVIDA A LINHA QUE IMPEDIA A ROLAGEM */
}

/* Acessibilidade */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Focus visível para navegação por teclado */
.tool-btn:focus,
.component-item:focus,
button:focus,
input:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Melhorias para leitores de tela */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================= */
/* ESTILOS PARA O TEMA ESCURO (DARK MODE)    */
/* ========================================= */

/* Quando o body tiver a classe 'dark-mode', estes estilos serão aplicados */
body.dark-mode {
    background-color: #1e293b; /* Fundo azul-escuro */
    color: #e2e8f0; /* Texto cinza-claro */
}

/* Altera a cor de fundo dos painéis, cabeçalhos e modais */
body.dark-mode .header,
body.dark-mode .toolbar,
body.dark-mode .sidebar,
body.dark-mode .properties-panel,
body.dark-mode .status-bar,
body.dark-mode .modal-content {
    background-color: #2c3e50; /* Um azul-escuro um pouco mais claro */
    border-color: #4a5a6a;
}

/* Altera a cor dos botões */
body.dark-mode .tool-btn,
body.dark-mode .component-item {
    background-color: #3e5169;
    color: #e2e8f0;
    border: 1px solid #5a6e83;
}

/* Efeito hover para os botões no tema escuro */
body.dark-mode .tool-btn:hover,
body.dark-mode .component-item:hover {
    background-color: #4f6a8a;
    border-color: #7a8fa6;
}

/* Altera a cor do canvas de desenho */
body.dark-mode #canvas {
    background-color: #334155; /* Fundo do canvas mais escuro */
}

/* Altera a cor do grid no canvas */
body.dark-mode .grid-line {
     stroke: #4a5a6a;
}
/* Layout CAD compacto */
#site-content,
#site-content .app-container {
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

#site-content .header {
    min-height: 44px;
    padding: 0.45rem 0.75rem;
    border-bottom-width: 1px;
    box-shadow: none;
}

#site-content .logo {
    font-size: 0.95rem;
    letter-spacing: 0;
}

#site-content .logo i {
    font-size: 1rem;
}

#site-content #user-info {
    gap: 0.5rem;
}

#site-content #user-info p {
    font-size: 0.75rem;
}

#site-content #user-info #logout-button {
    min-height: 32px;
    padding: 0.35rem 0.6rem;
}

.cad-toolbar {
    min-height: 50px;
    padding: 0.35rem 0.5rem;
    gap: 0.45rem;
    background: #eef2f7;
    border-bottom: 1px solid #cbd5e1;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.cad-toolbar .tool-group {
    gap: 0.25rem;
    padding: 0.25rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #f8fafc;
}

.cad-toolbar .tool-btn {
    min-height: 34px;
    padding: 0.35rem 0.55rem;
    border-radius: 4px;
    font-size: 0.75rem;
    gap: 0.35rem;
}

.cad-toolbar .tool-btn.icon-only {
    width: 34px;
    justify-content: center;
    padding: 0;
}

.cad-toolbar .tool-btn.icon-only span {
    display: none;
}

.main-content {
    display: grid;
    grid-template-columns: 172px minmax(320px, 1fr) 300px;
    height: calc(100vh - 44px - 50px - 32px);
    min-height: 0;
    overflow: hidden;
    background: #dfe6ee;
}

.cad-tool-palette,
.properties-panel {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem;
    border-radius: 0;
}

.cad-tool-palette {
    width: auto;
    border-right: 1px solid #cbd5e1;
    background: #f8fafc;
}

.properties-panel {
    width: auto;
    border-left: 1px solid #cbd5e1;
}

.cad-tool-palette .sidebar-section {
    margin-bottom: 0.75rem;
}

.cad-tool-palette .sidebar-section h3,
.properties-panel h3 {
    min-height: 28px;
    margin: 0 0 0.45rem;
    padding: 0 0 0.35rem;
    font-size: 0.78rem;
    border-bottom: 1px solid #d9e1ea;
}

.cad-tool-palette .component-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
}

.cad-tool-palette .component-item {
    width: 100%;
    min-height: 58px;
    margin: 0;
    padding: 0.35rem 0.25rem;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
    border-radius: 5px;
    font-size: 0.68rem;
    line-height: 1.1;
    text-align: center;
}

.cad-tool-palette .component-item i {
    font-size: 1rem;
}

.cad-tool-palette .component-item span,
.cad-toolbar .tool-btn span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cad-tool-palette .action-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.35rem;
}

.cad-tool-palette .action-buttons .tool-btn {
    width: 100%;
    justify-content: center;
    min-height: 34px;
    padding: 0.4rem;
    font-size: 0.72rem;
}

.canvas-container {
    min-width: 0;
    min-height: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #cfd8e3;
}

#canvas {
    border-radius: 0;
    box-shadow: none;
}

.properties-panel .properties-content {
    padding-bottom: 1rem;
}

.property-item {
    margin-bottom: 0.7rem;
}

.property-item label {
    margin-bottom: 0.25rem;
    font-size: 0.74rem;
}

.property-item input,
.property-item select {
    min-height: 32px;
    padding: 0.35rem 0.45rem;
    border-width: 1px;
    border-radius: 5px;
    font-size: 0.78rem;
}

.property-help {
    display: none;
}

.legend-area {
    display: none;
}

.status-bar {
    min-height: 32px;
    padding: 0.25rem 0.75rem;
    justify-content: flex-start;
    gap: 0.5rem;
    border-top: 1px solid #cbd5e1;
}

.status-bar span {
    padding: 0.15rem 0.45rem;
    font-size: 0.72rem;
}

@media (max-width: 1100px) {
    .main-content {
        grid-template-columns: 150px minmax(280px, 1fr) 260px;
    }

    .cad-tool-palette .component-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    #site-content,
    #site-content .app-container {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .main-content {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto 55vh auto;
        height: auto;
    }

    .cad-tool-palette {
        width: 100%;
        max-height: 34vh;
        border-right: 0;
        border-bottom: 1px solid #cbd5e1;
    }

    .cad-tool-palette .component-grid {
        grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
    }

    .properties-panel {
        width: 100%;
        max-height: 34vh;
        border-left: 0;
        border-top: 1px solid #cbd5e1;
    }
}

.validation-modal-content {
    max-width: 820px;
}

.project-preview-modal-content {
    max-width: 1120px;
}

.project-preview-body {
    display: grid;
    grid-template-columns: minmax(260px, 0.85fr) minmax(360px, 1.4fr);
    gap: 1rem;
    align-items: start;
}

.project-data-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.project-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.project-field-wide {
    grid-column: 1 / -1;
}

.project-field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #334155;
}

.project-field input,
.project-field textarea {
    width: 100%;
    min-height: 36px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.45rem 0.55rem;
    font: inherit;
    color: #0f172a;
    background: #ffffff;
}

.project-preview-sheet {
    background: #ffffff;
    color: #111827;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.8rem;
    box-shadow: var(--shadow-sm);
}

.project-preview-sheet header,
.project-preview-sheet footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: #475569;
    font-size: 0.78rem;
}

.project-preview-sheet header {
    align-items: flex-start;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.55rem;
    margin-bottom: 0.7rem;
}

.project-preview-sheet header div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.project-preview-sheet strong {
    color: #0f172a;
    font-size: 1rem;
}

.project-preview-sheet img {
    display: block;
    width: 100%;
    min-height: 260px;
    max-height: 420px;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid #e5e7eb;
}

.project-preview-sheet footer {
    border-top: 1px solid #e2e8f0;
    padding-top: 0.55rem;
    margin-top: 0.7rem;
}

.validation-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid #cbd5e1;
    border-left: 4px solid var(--success-color);
    border-radius: 6px;
    background: #f8fafc;
    color: #0f172a;
}

.validation-summary.error {
    border-left-color: var(--danger-color);
}

.validation-summary.warning {
    border-left-color: var(--accent-color);
}

.validation-summary.ok {
    border-left-color: var(--success-color);
}

.validation-results {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.validation-item {
    padding: 0.7rem 0.8rem;
    border: 1px solid #dbe3ef;
    border-left: 4px solid var(--success-color);
    border-radius: 6px;
    background: #ffffff;
}

.validation-item.error {
    border-left-color: var(--danger-color);
}

.validation-item.warning {
    border-left-color: var(--accent-color);
}

.validation-item.ok {
    border-left-color: var(--success-color);
}

.validation-item strong {
    display: block;
    margin-bottom: 0.25rem;
    color: #0f172a;
    font-size: 0.92rem;
}

.validation-item p {
    margin: 0;
    color: #475569;
    font-size: 0.84rem;
    line-height: 1.45;
}

/* Dark mode contrast fixes for compact CAD layout */
body.dark-mode {
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --bg-tertiary: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-light: #374151;
    --border-medium: #4b5563;
    --border-dark: #6b7280;
}

body.dark-mode .cad-toolbar {
    background: #111827;
    border-bottom-color: #374151;
}

body.dark-mode .cad-toolbar .tool-group,
body.dark-mode .property-group,
body.dark-mode .legend-summary,
body.dark-mode .legend-wiring,
body.dark-mode .legend-gauge {
    background: #1f2937;
    border-color: #374151;
}

body.dark-mode .main-content {
    background: #0f172a;
}

body.dark-mode .cad-tool-palette,
body.dark-mode .properties-panel {
    background: #111827;
    border-color: #374151;
    color: #f9fafb;
}

body.dark-mode .cad-tool-palette .sidebar-section h3,
body.dark-mode .properties-panel h3,
body.dark-mode .property-group h4,
body.dark-mode .property-item label,
body.dark-mode .auth-description,
body.dark-mode #user-info,
body.dark-mode #user-info p,
body.dark-mode .status-bar span,
body.dark-mode .report-section h4,
body.dark-mode .modal-header h3 {
    color: #f9fafb;
}

body.dark-mode .property-help,
body.dark-mode .text-secondary,
body.dark-mode .text-muted,
body.dark-mode .validation-item p {
    color: #d1d5db;
}

body.dark-mode .property-item input,
body.dark-mode .property-item select,
body.dark-mode .input-group input,
body.dark-mode textarea {
    background: #0f172a;
    color: #f9fafb;
    border-color: #4b5563;
}

body.dark-mode .property-item input::placeholder,
body.dark-mode .input-group input::placeholder,
body.dark-mode textarea::placeholder {
    color: #9ca3af;
}

body.dark-mode .property-item input:focus,
body.dark-mode .property-item select:focus,
body.dark-mode .input-group input:focus,
body.dark-mode textarea:focus {
    background: #111827;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
}

body.dark-mode .canvas-container {
    background: #1f2937;
}

body.dark-mode .canvas-control-btn {
    background: #111827;
    color: #f9fafb;
    border-color: #4b5563;
}

body.dark-mode .validation-summary,
body.dark-mode .validation-item,
body.dark-mode .legend-table-container,
body.dark-mode .wiring-legend-table th,
body.dark-mode .wiring-legend-table td {
    background: #111827;
    color: #f9fafb;
    border-color: #374151;
}

body.dark-mode .validation-item strong,
body.dark-mode .legend-table-container h3 {
    color: #f9fafb;
}

body.dark-mode .wiring-legend-table tr:hover {
    background: #1f2937;
}

body.dark-mode .secondary-btn,
body.dark-mode .google-btn {
    background: #1f2937;
    color: #f9fafb;
    border-color: #4b5563;
}

body.dark-mode .project-field label {
    color: #f9fafb;
}

body.dark-mode .project-field input,
body.dark-mode .project-field textarea {
    background: #0f172a;
    color: #f9fafb;
    border-color: #4b5563;
}

@media (max-width: 820px) {
    .project-preview-body,
    .project-data-form {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Estilos de Acordeão da Biblioteca de Símbolos Categorizada
   ========================================================================== */
.sidebar-accordion {
    border: 1.25px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    background: #ffffff;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-accordion[open] {
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.sidebar-accordion summary {
    padding: 10px 14px;
    font-weight: 600;
    font-size: 11px;
    color: #334155;
    cursor: pointer;
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    user-select: none;
    outline: none;
    border-bottom: 1.2px solid transparent;
    transition: all 0.2s ease;
}

.sidebar-accordion[open] summary {
    border-bottom-color: #e2e8f0;
    background: #f1f5f9;
    color: #0f172a;
}

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

.sidebar-accordion summary::after {
    content: '\f107';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    margin-left: auto;
    transition: transform 0.25s ease;
    font-size: 11px;
    color: #64748b;
}

.sidebar-accordion[open] summary::after {
    transform: rotate(180deg);
    color: #0f172a;
}

.sidebar-accordion .component-grid {
    padding: 8px;
    background: #ffffff;
    max-height: 250px;
    overflow-y: auto;
    border: none;
}

/* ==========================================================================
   Estilos da Lista de Projetos na Nuvem (Firebase)
   ========================================================================== */
.cloud-project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1.25px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s ease-in-out;
}

.cloud-project-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.cloud-project-item.active-cloud-project {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.04);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.cloud-project-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 70%;
    overflow: hidden;
}

.cloud-project-name {
    font-weight: 600;
    font-size: 11.5px;
    color: #1e293b;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.cloud-project-item.active-cloud-project .cloud-project-name {
    color: #2563eb;
}

.cloud-project-date {
    font-size: 9.5px;
    color: #64748b;
}

.cloud-project-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.cloud-project-btn {
    border: none;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s ease;
    outline: none;
}

.cloud-project-btn.load {
    background: #eff6ff;
    color: #2563eb;
}

.cloud-project-btn.load:hover {
    background: #2563eb;
    color: #ffffff;
}

.cloud-project-btn.delete {
    background: #fef2f2;
    color: #ef4444;
}

.cloud-project-btn.delete:hover {
    background: #ef4444;
    color: #ffffff;
}

/* Modo Escuro para Lista da Nuvem */
body.dark-mode .cloud-project-item {
    background: #1f2937;
    border-color: #374151;
}

body.dark-mode .cloud-project-item:hover {
    background: #374151;
    border-color: #4b5563;
}

body.dark-mode .cloud-project-item.active-cloud-project {
    border-color: #60a5fa;
    background: rgba(96, 165, 250, 0.08);
}

body.dark-mode .cloud-project-name {
    color: #f9fafb;
}

body.dark-mode .cloud-project-item.active-cloud-project .cloud-project-name {
    color: #60a5fa;
}

body.dark-mode .cloud-project-date {
    color: #9ca3af;
}

body.dark-mode .cloud-project-btn.load {
    background: #1e3a8a;
    color: #60a5fa;
}

body.dark-mode .cloud-project-btn.load:hover {
    background: #3b82f6;
    color: #ffffff;
}

body.dark-mode .cloud-project-btn.delete {
    background: #7f1d1d;
    color: #fca5a5;
}

body.dark-mode .cloud-project-btn.delete:hover {
    background: #ef4444;
    color: #ffffff;
}

.empty-cloud-projects {
    font-size: 11.5px;
    color: #64748b;
    text-align: center;
    padding: 15px 5px;
    font-style: italic;
}

/* ========================================================================= */
/* PREMIUM LOCK OVERLAY, BADGES AND UPGRADE MODAL                            */
/* ========================================================================= */

/* Badges for roles in header */
.role-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 9999px;
    text-transform: uppercase;
    margin-left: var(--space-xs);
    vertical-align: middle;
    transition: all var(--transition-fast);
}

.free-badge {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}

.free-badge:hover {
    background-color: var(--border-light);
    color: var(--primary-color);
}

.pro-badge {
    background: linear-gradient(135deg, var(--accent-color), #d97706);
    color: var(--text-white);
    border: 1px solid #d97706;
    box-shadow: var(--shadow-sm);
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

/* Blur the background sections when locked */
.modal-body.locked-content {
    position: relative;
    min-height: 400px;
}

.modal-body.locked-content > *:not(.reports-lock-overlay) {
    filter: blur(5px);
    pointer-events: none;
    user-select: none;
    opacity: 0.6;
}

/* Glassmorphism locking overlay for Free users */
.reports-lock-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--space-xl);
    text-align: center;
    border-bottom-left-radius: var(--radius-xl);
    border-bottom-right-radius: var(--radius-xl);
}

.reports-lock-container {
    max-width: 520px;
    background: var(--bg-primary);
    padding: var(--space-2xl);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    animation: fadeInUp 0.4s ease-out;
}

.reports-lock-icon {
    font-size: 3.2rem;
    color: var(--accent-color);
    margin-bottom: 5px;
}

.reports-lock-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.reports-lock-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.reports-lock-btn {
    padding: var(--space-md) var(--space-2xl);
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-color), #d97706);
    color: var(--text-white);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reports-lock-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Dark mode compatibility for lock overlay */
body.dark-mode .reports-lock-overlay {
    background: rgba(15, 23, 42, 0.6);
}
body.dark-mode .reports-lock-container {
    background: var(--bg-dark);
    border-color: var(--border-dark);
}

/* ========================================================================= */
/* UPGRADE TO PRO UPGRADE MODAL STYLES                                       */
/* ========================================================================= */
.upgrade-modal-content {
    max-width: 780px !important;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-xl);
    margin-top: var(--space-lg);
}

@media (max-width: 640px) {
    .plans-grid {
        grid-template-columns: 1fr;
    }
}

.plan-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl) var(--space-xl);
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all var(--transition-normal);
}

.plan-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-light);
}

.plan-card.popular {
    border-color: var(--accent-color);
    background: var(--bg-primary);
}

.plan-card.popular::before {
    content: "RECOMENDADO";
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-color);
    color: var(--text-white);
    padding: 3px 12px;
    font-size: 0.68rem;
    font-weight: 800;
    border-radius: 999px;
    letter-spacing: 1px;
}

.plan-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.plan-price {
    margin: var(--space-md) 0;
}

.plan-price .currency {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.plan-price .amount {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.plan-price .period {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: var(--space-lg) 0;
    text-align: left;
}

.plan-features li {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.plan-features li i {
    color: var(--success-color);
    font-size: 0.95rem;
}

.plan-btn {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-white);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.plan-card:not(.popular) .plan-btn {
    background: var(--primary-color);
}

.plan-card:not(.popular) .plan-btn:hover {
    background: var(--primary-dark);
}

.plan-card.popular .plan-btn {
    background: linear-gradient(135deg, var(--accent-color), #d97706);
}

.plan-card.popular .plan-btn:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
}

/* Dark mode compatibility for cards */
body.dark-mode .plan-card {
    background: var(--bg-dark);
    border-color: var(--border-dark);
}
body.dark-mode .plan-card.popular {
    background: rgba(30, 41, 59, 0.5);
}

