﻿/* ===================================================================
   WEBPLAN DESIGN SYSTEM - MAIN.CSS
   Estilo moderno, profissional e de alta fidelidade
   =================================================================== */

:root {
    /* Paleta Principal */
    --bg-app: #0b101b;
    --bg-surface: #111827;
    --bg-surface-alt: #162032;
    --bg-surface-elevated: #1e293b;
    --border-color: #24324a;
    --border-subtle: #334155;
    --header-bg: rgba(17, 24, 39, 0.85);

    /* Cores de Marca & Acentos */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.15);
    --primary-glow: rgba(37, 99, 235, 0.25);
    
    --accent: #06b6d4;
    --accent-light: rgba(6, 182, 212, 0.12);

    /* Textos */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    /* Status Semânticos */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.15);

    /* Grupos Funcionais da Planilha */
    /* Grupos Funcionais da Planilha */
    --grp-impacto-bg: #92400e;
    --grp-impacto-text: #fef3c7;
    --grp-processo-bg: #1e3a8a;
    --grp-processo-text: #dbeafe;
    --grp-problema-bg: #991b1b;
    --grp-problema-text: #fee2e2;
    --grp-tratativa-bg: #065f46;
    --grp-tratativa-text: #d1fae5;
    --grp-recorrencia-bg: #5b21b6;
    --grp-recorrencia-text: #ede9fe;

    --formula-bg: #1c273c;
    --formula-text: #93c5fd;

    --cascade-parent-text: #67e8f9;
    --cascade-child-text: #cbd5e1;

    --table-row-even-bg: rgba(17, 24, 39, 0.4);

    /* Tipografia e Raios */
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', var(--font-sans);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 25px rgba(37, 99, 235, 0.2);
}

[data-theme="light"] {
    /* Paleta Principal Light */
    --bg-app: #e2e8f0;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f8fafc;
    --bg-surface-elevated: #ffffff;
    --border-color: #cbd5e1;
    --border-subtle: #cbd5e1;
    --header-bg: rgba(255, 255, 255, 0.9);

    /* Cores de Marca Light */
    --primary-light: rgba(37, 99, 235, 0.08);
    --primary-glow: rgba(37, 99, 235, 0.15);
    --accent-light: rgba(6, 182, 212, 0.08);

    /* Textos Light */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Sombras Light */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);

    /* Grupos Funcionais Light */
    --grp-impacto-bg: #fef3c7;
    --grp-impacto-text: #92400e;
    --grp-processo-bg: #dbeafe;
    --grp-processo-text: #1e3a8a;
    --grp-problema-bg: #fee2e2;
    --grp-problema-text: #991b1b;
    --grp-tratativa-bg: #d1fae5;
    --grp-tratativa-text: #065f46;
    --grp-recorrencia-bg: #ede9fe;
    --grp-recorrencia-text: #5b21b6;

    --formula-bg: #f1f5f9;
    --formula-text: #0f172a;

    --cascade-parent-text: #0284c7;
    --cascade-child-text: #475569;

    --table-row-even-bg: #ffffff;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header da Aplicação */
.app-header {
    background-color: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-badge {
    font-size: 0.72rem;
    padding: 2px 7px;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--accent);
    border-radius: 999px;
    margin-left: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.nav-item:hover, .nav-item.active {
    color: #ffffff;
    background-color: var(--bg-surface-elevated);
}

.header-status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background-color: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 4px 10px;
    border-radius: 999px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

/* Área Principal */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ==================== TELA A: DASHBOARD ==================== */
.dashboard-page {
    max-width: 1440px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    width: 100%;
}

.dashboard-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    background-color: var(--accent-light);
    border: 1px solid rgba(6, 182, 212, 0.25);
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 0.85rem;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #ffffff;
    margin-bottom: 0.75rem;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 720px;
    line-height: 1.6;
}

.dashboard-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1.5rem;
    flex-wrap: wrap;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-lg);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    flex: 1;
    max-width: 420px;
    color: var(--text-muted);
}

.search-box input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 100%;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.toolbar-stats {
    display: flex;
    gap: 0.75rem;
}

.stat-pill {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background-color: var(--bg-surface-elevated);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.stat-pill.highlight {
    border-color: rgba(37, 99, 235, 0.35);
    background-color: var(--primary-light);
    color: #93c5fd;
}

/* Grid de Cards */
.sheets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.5rem;
}

.sheet-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.sheet-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sheet-card:hover {
    transform: translateY(-4px);
    border-color: rgba(37, 99, 235, 0.45);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.sheet-card:hover::before {
    opacity: 1;
}

.sheet-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sheet-card-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.sheet-card-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1.25rem;
    flex: 1;
}

.sheet-card-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
}

.metric-item {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.metric-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sheet-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-subtle);
    padding-top: 1rem;
}

.sheet-timestamp {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ==================== COMPONENTES GERAIS ==================== */

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #1d4ed8);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

.btn-secondary {
    background-color: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #273549;
    border-color: #3b4d68;
}

.btn-outline {
    background: transparent;
    color: #93c5fd;
    border: 1px solid rgba(37, 99, 235, 0.4);
}

.btn-outline:hover {
    background-color: var(--primary-light);
    color: #ffffff;
    border-color: var(--primary);
}

.btn-lg {
    padding: 0.75rem 1.4rem;
    font-size: 0.98rem;
    font-weight: 600;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* Badges */
.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
}

.badge-category {
    background-color: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-status {
    background-color: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

/* Modais */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 580px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-sm {
    max-width: 440px;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-surface-alt);
}

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.modal-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    color: #60a5fa;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: #ffffff;
}

.modal-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.btn-close:hover {
    color: #ffffff;
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background-color: var(--bg-surface-alt);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Formulários */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.flex-1 {
    flex: 1;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input, .form-textarea, .form-select {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.info-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background-color: var(--primary-light);
    border: 1px solid rgba(37, 99, 235, 0.25);
    padding: 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    color: #93c5fd;
    line-height: 1.45;
}

/* Utilitários de Texto */
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-success { color: var(--success) !important; }
.text-muted { color: var(--text-muted) !important; }

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideInRight 0.25s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }

/* Animações */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(50px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==================== AUTENTICAÇÃO / LOGIN ==================== */
.login-wrapper {
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
    padding: 2.5rem 2rem;
    animation: slideUp 0.3s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo-badge {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
    margin-bottom: 1rem;
}

.login-title {
    font-size: 1.85rem;
    font-weight: 700;
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 0.35rem;
}

.login-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-size: 0.88rem;
}

.login-alert.error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon svg {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-with-icon input {
    padding-left: 42px;
}

.form-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.btn-block {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.login-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-subtle);
}

.login-demo-pill {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.demo-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.demo-chips {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.demo-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: monospace;
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-fast);
}

.demo-chip:hover {
    background: rgba(37, 99, 235, 0.12);
    border-color: var(--primary);
    color: #ffffff;
}

.chip-role {
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.chip-role.master {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.chip-role.user {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

/* ==================== USUÁRIO NO HEADER ==================== */
.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0.65rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.user-avatar-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #ffffff;
}

.user-avatar-badge.master {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.user-avatar-badge.user {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.user-text-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.user-name-display {
    font-size: 0.82rem;
    font-weight: 600;
    color: #ffffff;
}

.user-role-pill {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.user-role-pill.master {
    color: #fbbf24;
}

.user-role-pill.user {
    color: #60a5fa;
}

.btn-logout {
    color: #f87171 !important;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.12) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

