:root {
    --primary: #2563eb; --secondary: #1e40af; --success: #16a34a;
    --danger: #dc2626; --warning: #ca8a04; --info: #06b6d4;
    --bg: #f3f4f6; --card-bg: #ffffff; --text: #1f2937;
    --text-light: #6b7280; --border: #e5e7eb;
    --input-bg: #e0f2fe; --input-border: #93c5fd;
    --st-scheduled: #3b82f6; --st-done: #22c55e; --st-canceled: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', system-ui, sans-serif; }
body { background-color: var(--bg); color: var(--text); height: 100vh; display: flex; flex-direction: column; }

/* FIX: Reforço para garantir que elementos ocultos não apareçam */
.hidden { display: none !important; visibility: hidden !important; opacity: 0 !important; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.p-4 { padding: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.font-bold { font-weight: bold; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }
.text-info { color: var(--info); }
.text-warning { color: var(--warning); }

label { display: block; margin-bottom: 0.25rem; font-weight: 600; font-size: 0.9rem; margin-top: 0.5rem; }

input, select, textarea {
    width: 100%; padding: 0.75rem; border: 1px solid var(--input-border); 
    background-color: var(--input-bg); border-radius: 0.375rem; 
    margin-bottom: 0.5rem; outline: none; color: #0f172a; font-weight: 500;
}
input:focus, select:focus, textarea:focus { 
    border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2); background-color: #dbeafe;
}
input[readonly] { background-color: #f3f4f6; border-color: #d1d5db; color: #4b5563; }

button { padding: 0.75rem 1rem; border: none; border-radius: 0.375rem; cursor: pointer; font-weight: 600; transition: 0.2s; }
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--secondary); }
.btn-success { background-color: var(--success); color: white; }
.btn-danger { background-color: var(--danger); color: white; }
.btn-warning { background-color: var(--warning); color: white; }
.btn-info { background-color: var(--info); color: white; }

.btn-outline { background-color: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background-color: rgba(37, 99, 235, 0.1); }
.btn-outline.active { background-color: var(--primary); color: white; }

.google-btn { background-color: #db4437; color: white; }
.action-btn { padding: 0.4rem 0.6rem; font-size: 0.85rem; margin-right: 0.25rem; margin-bottom: 0; }

#auth-screen { flex: 1; display: flex; justify-content: center; align-items: center; background: linear-gradient(135deg, var(--primary), var(--secondary)); width: 100%; height: 100vh; position: absolute; top:0; left:0; z-index: 50; }
.auth-card { background: var(--card-bg); padding: 2rem; border-radius: 0.5rem; width: 100%; max-width: 400px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }

#app-container { display: flex; flex: 1; height: 100vh; overflow: hidden; width: 100%; }

aside { width: 250px; background-color: #111827; color: white; display: flex; flex-direction: column; padding: 1rem; transition: transform 0.3s; z-index: 10; flex-shrink: 0; }
aside h2 { margin-bottom: 2rem; text-align: center; font-size: 1.5rem; }
.nav-item { padding: 0.75rem; cursor: pointer; border-radius: 0.375rem; margin-bottom: 0.25rem; display: flex; align-items: center; gap: 0.75rem; }
.nav-item:hover, .nav-item.active { background-color: #374151; }
.user-info { margin-top: auto; padding-top: 1rem; border-top: 1px solid #374151; font-size: 0.875rem; }

/* Botão Sync Manual na Sidebar */
.btn-sync { 
    background-color: #374151; color: white; border: 1px solid #4b5563; 
    padding: 0.4rem; border-radius: 0.25rem; width: 100%; margin-top: 0.5rem;
    font-size: 0.8rem; display: flex; justify-content: center; align-items: center; gap: 5px;
}
.btn-sync:hover { background-color: #4b5563; }

main { flex: 1; overflow-y: auto; padding: 1.5rem; position: relative; width: 100%; }
.view-header { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }

.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.stat-card { background: var(--card-bg); padding: 1.5rem; border-radius: 0.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 1rem; }
.stat-value { font-size: 1.5rem; font-weight: bold; margin-top: 0.5rem; }
.stat-sub { font-size: 0.9rem; color: var(--text-light); margin-top: 0.25rem; }

.agenda-card { border-left: 5px solid var(--primary); position: relative; }
.agenda-card.status-agendado { border-left-color: var(--st-scheduled); }
.agenda-card.status-concluido { border-left-color: var(--st-done); }
.agenda-card.status-cancelado { border-left-color: var(--st-canceled); opacity: 0.7; }

.badge { padding: 0.2rem 0.5rem; border-radius: 1rem; font-size: 0.75rem; color: white; font-weight: bold; text-transform: uppercase; }
.bg-scheduled { background-color: var(--st-scheduled); }
.bg-done { background-color: var(--st-done); }
.bg-canceled { background-color: var(--st-canceled); }

.table-container { overflow-x: auto; background: var(--card-bg); border-radius: 0.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background-color: #f9fafb; font-weight: 600; }
tr:hover { background-color: #f9fafb; }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal { background: var(--card-bg); padding: 2rem; border-radius: 0.5rem; width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; }

.sync-status { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.sync-online { background-color: var(--success); box-shadow: 0 0 5px var(--success); }
.sync-offline { background-color: var(--text-light); }

#loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg); z-index: 9999;
    display: flex; justify-content: center; align-items: center; flex-direction: column;
}
.loader { border: 4px solid #f3f3f3; border-top: 4px solid var(--primary); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin-bottom: 1rem; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

@media (max-width: 768px) {
    #app-container { flex-direction: column; }
    aside { width: 100%; height: auto; flex-direction: row; overflow-x: auto; padding: 0.5rem; }
    aside h2, .user-info { display: none; }
    .nav-item { flex: 0 0 auto; margin: 0; font-size: 0.8rem; }
    .dash-grid { grid-template-columns: 1fr; }
}

.notification-bar { background-color: var(--warning); color: white; padding: 0.5rem; text-align: center; font-weight: bold; font-size: 0.9rem; }
.tabs { display: flex; gap: 0.5rem; overflow-x: auto; border-bottom: 2px solid var(--border); padding-bottom: 0.5rem; margin-bottom: 1rem; }
.tab-btn { padding: 0.5rem 1rem; background: none; border: none; cursor: pointer; font-weight: 600; color: var(--text-light); border-radius: 0.25rem; white-space: nowrap; }
.tab-btn.active { background-color: var(--primary); color: white; }

.rpa-paper { background: white; border: 1px solid #ccc; padding: 2rem; max-width: 800px; margin: 0 auto; }
.rpa-section { margin-bottom: 1rem; border: 1px solid #eee; padding: 1rem; border-radius: 4px; }
.rpa-section h4 { margin-bottom: 0.5rem; border-bottom: 2px solid #eee; padding-bottom: 0.25rem; color: var(--primary); }

@media print {
    aside, .notification-bar, .view-header, .no-print, .tabs { display: none !important; }
    #app-container { height: auto; display: block; }
    main { padding: 0; overflow: visible; background: white; }
    body { background: white; }
    .table-container { box-shadow: none; border: none; }
    table { width: 100%; border: 1px solid #000; }
    th, td { border: 1px solid #000; padding: 5px; font-size: 12px; }
    #rpa-content { border: none; box-shadow: none; padding: 0; }
    .rpa-paper { border: none; padding: 0; width: 100%; max-width: none; }
    input, select { border: none; background: transparent; padding: 0; font-weight: bold; }
    section:not(.active-print) { display: none !important; }
}