/* Hide print-only elements on screen */
@media screen {
    .print-only { display: none !important; }
}
@media print {
    /* Ocultar elementos de navegação e ações */
    .no-print,
    .sidebar,
    .topbar,
    .btn-icon,
    .terminal-btn { display: none !important; }

    /* Layout limpo */
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    body, .modern-body { background: #fff !important; }

    /* Forçar fundo branco e texto escuro em TODOS os elementos */
    *,
    *::before,
    *::after {
        background: #fff !important;
        background-color: #fff !important;
        color: #111 !important;
        box-shadow: none !important;
        border-color: #ddd !important;
    }

    /* Exceções de cor para status (mantém legibilidade) */
    [style*="color:#dc2626"], [style*="color: #dc2626"] { color: #dc2626 !important; }
    [style*="color:#15803d"], [style*="color: #15803d"] { color: #15803d !important; }
    [style*="color:#854d0e"], [style*="color: #854d0e"] { color: #854d0e !important; }

    /* Garante que o conteúdo imprimível fique visível */
    .printable-area, .print-only { display: block !important; }
}

:root {
    --bg-main: #f3f4f6;
    --bg-sidebar: #ffffff;
    --bg-header: #ffffff;
    --bg-body: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --text-desc: #4b5563;
    --text-sidebar: #4b5563;
    --text-sidebar-hover: #2563eb;
    --border-color: #e5e7eb;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;

    --sidebar-width: 250px;
    --sidebar-collapsed-width: 80px;
}

body.modern-body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    height: 100vh;
    position: fixed;
    display: flex;
    flex-direction: column;
    color: var(--text-sidebar);
    z-index: 1000;
    transition: width 0.3s ease;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #0f2547 0%, #1d4ed8 60%, #2563eb 100%);
    border-bottom: none;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(37,99,235,0.35);
}
.sidebar-header::before {
    content: '';
    position: absolute;
    top: -30px; right: -30px;
    width: 120px; height: 120px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    pointer-events: none;
}
.sidebar-header::after {
    content: '';
    position: absolute;
    bottom: -20px; left: -20px;
    width: 80px; height: 80px;
    background: radial-gradient(circle, rgba(99,179,237,0.15) 0%, transparent 70%);
    pointer-events: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(37,99,235,0.2) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(37,99,235,0.2); border-radius: 4px; }

.nav-label {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    padding: 6px 16px 5px 16px;
    margin: 6px 0 2px 0;
    color: var(--primary);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}
.nav-label::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    opacity: 0.7;
}
.nav-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(37,99,235,0.25), transparent);
    display: block;
}
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 4px 16px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.18s ease;
    border-left: 3px solid transparent;
    border-radius: 0 8px 8px 0;
    margin: 0 8px 0 0;
}
.sidebar-nav li a i { font-size: 1.15rem; min-width: 20px; margin-right: 12px; color: var(--text-muted); transition: color 0.18s; }
.sidebar-nav li a:hover {
    color: var(--primary);
    background-color: rgba(37, 99, 235, 0.07);
    border-left-color: var(--primary);
}
.sidebar-nav li a:hover i { color: var(--primary); }
.sidebar-nav li a.active {
    color: var(--primary);
    background: linear-gradient(90deg, rgba(37,99,235,0.1) 0%, rgba(37,99,235,0.03) 100%);
    border-left-color: var(--primary);
    font-weight: 600;
}
.sidebar-nav li a.active i { color: var(--primary); }

.sidebar-footer { padding: 15px; background: #f8fafc; border-top: 1px solid var(--border-color); }
.user-profile { display: flex; align-items: center; gap: 10px; }
.user-profile .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.2rem;
}
.user-info { flex: 1; display: flex; flex-direction: column; }
.user-info .user-name { font-weight: 600; font-size: 0.85rem; color: var(--text-main); }
.user-info .user-role { font-size: 0.75rem; color: var(--text-muted); }
.logout-btn { color: var(--danger); cursor: pointer; text-decoration: none; }
.logout-btn:hover { color: #b91c1c; }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.topbar {
    height: 60px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky; top: 0; z-index: 999;
}

.topbar-search {
    display: flex; align-items: center;
    background: #f1f5f9; padding: 8px 16px; border-radius: 20px; width: 300px;
}
.topbar-search input {
    border: none; background: transparent; outline: none; margin-left: 10px; width: 100%; font-size: 0.9rem;
}
.sys-btn { background: none; border: none; font-size: 1.2rem; color: var(--text-muted); cursor: pointer; }
.sys-btn:hover { color: var(--text-main); }

.content-wrapper { padding: 30px; }

/* Overrides for Legacy Elements */
.card-panel {
    background: var(--bg-body) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    padding: 24px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    color: var(--text-main) !important;
    margin-bottom: 24px;
}
.card-panel h2, .card-panel h3 {
    margin-top: 0;
    color: var(--text-main) !important;
    font-size: 1.2rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color) !important;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.data-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 0.9rem;
}
.data-table th {
    background: #f8fafc !important;
    color: var(--text-desc) !important;
    font-weight: 600 !important;
    text-align: left;
    padding: 12px 16px !important;
    border-bottom: 2px solid var(--border-color) !important;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}
.data-table td {
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
}
.data-table tr:last-child td { border-bottom: none !important; }

/* Inputs and Forms */
.input-line { margin-bottom: 16px; }
.input-line label { font-weight: 500; font-size: 0.85rem; color: var(--text-desc); margin-bottom: 6px; display: block; }
.input-line input, .input-line select, .input-line textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    background: #fff !important;
    color: var(--text-main) !important;
    font-size: 0.95rem;
    box-sizing: border-box;
}
.input-line input:focus, .input-line select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
    outline: none !important;
}

/* Buttons */
.terminal-btn {
    background: var(--primary) !important;
    color: #fff !important;
    border: 2px solid transparent !important;
    border-radius: 8px !important;
    padding: 10px 20px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    font-size: 0.95rem !important;
    transition: background 0.2s, opacity 0.2s !important;
    text-decoration: none !important;
}
.terminal-btn:hover { background: var(--primary-hover) !important; opacity: 0.92; }

/* Variantes de cor — texto sempre branco */
.terminal-btn.btn-success { background: #10b981 !important; border-color: #10b981 !important; }
.terminal-btn.btn-success:hover { background: #059669 !important; }
.terminal-btn.btn-warning { background: #f59e0b !important; border-color: #f59e0b !important; }
.terminal-btn.btn-warning:hover { background: #d97706 !important; }
.terminal-btn.btn-danger  { background: #ef4444 !important; border-color: #ef4444 !important; }
.terminal-btn.btn-danger:hover  { background: #dc2626 !important; }
.terminal-btn.btn-info    { background: #0ea5e9 !important; border-color: #0ea5e9 !important; }
.terminal-btn.btn-info:hover    { background: #0284c7 !important; }
.terminal-btn.btn-outline { background: transparent !important; border-color: var(--primary) !important; color: var(--primary) !important; }
.terminal-btn.btn-outline:hover { background: rgba(37,99,235,0.08) !important; }

/* Global Flashes */
.global-flashes {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-weight: 500;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.alert-success { background: #dcfce7; color: #166534; border-left: 4px solid var(--success); }
.alert-error { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-warning { background: #fef9c3; color: #854d0e; border-left: 4px solid var(--warning); }

/* Fix Status texts from old system */
.status-orcamento { color: var(--warning); font-weight: bold; }
.status-aprovado { color: var(--info); font-weight: bold; }
.status-concluido { color: var(--success); font-weight: bold; }
.status-cancelado { color: var(--danger); font-weight: bold; }
.status-atrasado { color: var(--danger); font-weight: bold; }
.status-pendente { color: var(--warning); font-weight: bold; }

/* Phosphor Action Buttons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 6px;
    transition: transform 0.1s, background 0.2s;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.2rem;
}
.btn-icon:hover {
    background: rgba(0,0,0,0.05);
    transform: translateY(-1px);
}
.btn-icon.edit-icon { color: var(--primary); }
.btn-icon.view-icon { color: var(--info); }
.btn-icon.delete-icon { color: var(--danger); }

/* Sidebar Responsive Collapsed State */
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .nav-label { display: none; }
body.sidebar-collapsed .sidebar-nav li a p { display: none; }
body.sidebar-collapsed .sidebar-nav li a { padding: 12px 0; justify-content: center; }
body.sidebar-collapsed .sidebar-nav li a i { margin-right: 0; font-size: 1.5rem; }
body.sidebar-collapsed .user-info, body.sidebar-collapsed .logout-btn { display: none; }
body.sidebar-collapsed .sidebar-header img { display: none; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
    .main-content { margin-left: 0; }
    body.sidebar-collapsed .sidebar { transform: translateX(0); }
    body.sidebar-collapsed .main-content { margin-left: 0; }
}

/* Print-only elements: hidden on screen, visible only when printing */
.print-only { display: none !important; }

@media print {
    .print-only { display: block !important; }
    .sidebar, .topbar { display: none !important; }
    .main-content { margin-left: 0 !important; }
}
