/* 
 * Scanner B3 - Estilos Globais (Tema Professional Polish)
 */

:root {
    --bg-main: #f4f7f9;
    --sidebar-bg: #101d3f;
    --sidebar-hover: #1a2c5a;
    --primary: #3182ce;
    --primary-hover: #2b6cb0;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1a202c;
    --text-muted: #718096;
    --text-secondary: #4a5568;
    --green-up: #38a169;
    --red-down: #e53e3e;
    --font-sans: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Courier New', Consolas, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
aside.sidebar {
    width: 240px;
    background-color: var(--sidebar-bg);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #0a1428;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
}

aside.sidebar .logo {
    padding: 24px;
    font-size: 20px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--sidebar-hover);
    display: flex;
    align-items: center;
    gap: 8px;
}

aside.sidebar .logo span {
    color: var(--primary);
}

aside.sidebar nav {
    padding: 20px 0;
    flex: 1;
}

.nav-item {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #a0aec0;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
    user-select: none;
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: #ffffff;
}

.nav-item.active {
    background-color: var(--sidebar-hover);
    color: #ffffff;
    border-left-color: var(--primary);
    font-weight: 600;
}

aside.sidebar .sidebar-footer {
    padding: 20px 24px;
    font-size: 11px;
    color: #4a5568;
    border-top: 1px solid var(--sidebar-hover);
}

/* Main Content Area */
main.main-content {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top Bar */
.top-bar {
    min-height: 64px;
    height: auto;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 24px;
    gap: 16px;
    flex-wrap: wrap;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.market-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-indicator {
    color: var(--green-up);
    font-weight: 700;
}

.status-indicator.market-open {
    color: var(--green-up);
}

.status-indicator.market-closed {
    color: var(--red-down);
}

.divider {
    color: #cbd5e0;
}

/* Page Views */
.content {
    padding: 24px;
    flex: 1;
}

.page-view {
    display: none;
}

.page-view.active {
    display: block;
}

/* Section Titles & Cards */
.page-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Dashboard Grid */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.card-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.trend-up {
    color: var(--green-up);
    font-size: 12px;
    font-weight: 700;
}

.trend-down {
    color: var(--red-down);
    font-size: 12px;
    font-weight: 700;
}

/* Tables */
.scanner-table-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

.table-title-bar {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 14px;
    background: #fafbfc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: #f8fafc;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tr:hover td {
    background-color: #f8fafc;
}

.ticker {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--sidebar-bg);
    font-size: 14px;
}

.score-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 700;
    text-align: center;
    font-size: 11px;
    display: inline-block;
    min-width: 36px;
}

.score-high {
    background: #c6f6d5;
    color: #22543d;
}

.score-med {
    background: #feebc8;
    color: #744210;
}

.score-low {
    background: #fed7d7;
    color: #9b2c2c;
}

.badge-signal {
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-buy {
    background: #e6fffa;
    color: #234e52;
    border: 1px solid #b2f5ea;
}

.badge-sell {
    background: #fff5f5;
    color: #742a2a;
    border: 1px solid #feb2b2;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #edf2f7;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

/* Inputs */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    background: #ffffff;
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.2);
}

/* Stock Chart & Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(16, 29, 63, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background: #ffffff;
    border-radius: 6px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.modal-body {
    padding: 24px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}

.close-btn:hover {
    color: var(--text-primary);
}

.chart-box {
    width: 100%;
    height: 320px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    margin-bottom: 20px;
}

canvas#stockCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Indicators Grid */
.indicators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.ind-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    text-align: center;
}

.ind-name {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.ind-val {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

/* Backtest Results Cards */
.backtest-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.metric-box {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 14px;
    text-align: center;
}

.metric-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.metric-value {
    font-size: 18px;
    font-weight: 700;
    margin-top: 4px;
    color: var(--text-primary);
}

/* Utility classes */
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-12 { gap: 12px; }
.mt-20 { margin-top: 20px; }

/* Toast Notifications Container */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: #1e293b;
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid var(--primary);
}

.toast.toast-success {
    border-left-color: #22c55e;
}

.toast.toast-error {
    border-left-color: #ef4444;
}

.toast.toast-info {
    border-left-color: #3b82f6;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Brand Logo & Sidebar */
aside.sidebar .logo {
    padding: 20px 24px;
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--sidebar-hover);
    display: flex;
    align-items: center;
    gap: 12px;
}

aside.sidebar .brand-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 18px;
    font-weight: 800;
    color: #f8fafc;
}

aside.sidebar .brand-badge {
    background: linear-gradient(135deg, #3182ce 0%, #2b6cb0 100%);
    color: #ffffff;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* User Profile Badge in Header */
.user-profile-badge {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3182ce 0%, #1e40af 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(49, 130, 206, 0.2);
}

.avatar-circle-lg {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3182ce 0%, #1e40af 100%);
    color: #ffffff;
    font-weight: 800;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    box-shadow: 0 4px 6px rgba(49, 130, 206, 0.25);
}

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

.user-name {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.user-role-tag {
    font-size: 10px;
    color: #64748b;
    font-weight: 600;
}

.btn-profile-action {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-profile-action:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-logout-action {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--red-down);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout-action:hover {
    background: #fee2e2;
    color: #991b1b;
}

/* Login Screen Styles */
.login-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #090d16 0%, #0f172a 50%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.login-card {
    background: #ffffff;
    width: 100%;
    max-width: 440px;
    border-radius: 20px;
    padding: 40px 36px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.login-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.login-brand-title {
    font-size: 26px;
    font-weight: 900;
    color: #0f172a;
    letter-spacing: -0.5px;
}

.login-brand-title span {
    color: var(--primary);
    background: linear-gradient(135deg, #3182ce 0%, #2563eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
}

.admin-notice-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 14px 16px;
    margin-top: 24px;
    font-size: 12px;
    color: #1e40af;
    line-height: 1.5;
}

.admin-notice-box strong {
    color: #1d4ed8;
}

