/* styles.css - Ponto Pro Enterprise v4.0 */
:root {
  --primary: #1d4ed8; 
  --success: #10b981; 
  --danger: #ef4444; 
  --warning: #f59e0b;
  --gray: #6b7280; 
  --light: #f8fafc; 
  --dark: #1f2937; 
  --bg: #ffffff; 
  --text: #1f2937;
  --border: #d1d5db; 
  --shadow: rgba(0,0,0,0.1);
  --chart-bg: #f9fafb;
  --chart-grid: #e5e7eb;
}

[data-theme="dark"] {
  --bg: #0f172a; 
  --text: #f3f4f6; 
  --light: #1e293b; 
  --gray: #9ca3af; 
  --dark: #f3f4f6;
  --border: #374151; 
  --shadow: rgba(0,0,0,0.3);
  --chart-bg: #1e293b;
  --chart-grid: #374151;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f172a; --text: #f3f4f6; --light: #1e293b; --gray: #9ca3af; --dark: #f3f4f6;
    --border: #374151; --shadow: rgba(0,0,0,0.3);
    --chart-bg: #1e293b; --chart-grid: #374151;
  }
}

/* Reset & Base */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(135deg, #e0e7ff, #dbeafe);
  color: var(--text);
  padding: 16px;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
}
[data-theme="dark"] body { background: linear-gradient(135deg, #0f172a, #1e293b); }

/* Utilitários */
.hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.positivo { color: var(--success); }
.negativo { color: var(--danger); }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Layout */
.container { 
  max-width: 1200px; 
  margin: auto; 
  background: var(--bg); 
  border-radius: 16px; 
  box-shadow: 0 10px 30px var(--shadow); 
  overflow: hidden; 
}

/* Header */
header { 
  background: var(--primary); 
  color: white; 
  padding: 1rem 1.5rem; 
}
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.user-info { display: flex; align-items: center; gap: 1rem; }
.role-badge { 
  background: rgba(255,255,255,0.2); 
  padding: 0.25rem 0.75rem; 
  border-radius: 1rem; 
  font-size: 0.875rem; 
}
.actions { display: flex; gap: 0.5rem; align-items: center; }

/* Tabs */
.tabs { 
  display: flex; 
  background: var(--light); 
  border-bottom: 1px solid var(--border); 
  flex-wrap: wrap; 
}
.tab { 
  padding: 0.875rem 1.25rem; 
  cursor: pointer; 
  font-weight: 600; 
  color: var(--gray); 
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.tab:hover { color: var(--primary); background: rgba(255,255,255,0.1); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; padding: 1.5rem; }
.tab-content.active { display: block; }

/* Formulários */
.form-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); 
  gap: 0.875rem; 
  margin-bottom: 1rem; 
}
label { 
  font-weight: 600; 
  font-size: 0.9rem; 
  display: block; 
  margin-bottom: 0.25rem; 
  color: var(--text);
}
input, select, button, textarea { 
  padding: 0.625rem; 
  border: 1px solid var(--border); 
  border-radius: 8px; 
  font-size: 1rem; 
  background: var(--bg); 
  color: var(--text);
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

/* Botões */
button { 
  background: var(--primary); 
  color: white; 
  border: none; 
  cursor: pointer; 
  font-weight: 600; 
  transition: all 0.2s;
  border-radius: 8px;
  padding: 0.625rem 1rem;
}
button:hover { opacity: 0.9; transform: translateY(-1px); }
button:active { transform: translateY(0); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-warning { background: var(--warning); color: white; }
.theme-toggle, .btn-icon { 
  background: rgba(255,255,255,0.2); 
  padding: 0.5rem 0.75rem; 
  font-size: 1.1rem;
  border-radius: 8px;
}
#googleLogin {
  background: #4285F4;
  margin-top: 0.5rem;
}
#googleLogin:hover { background: #3367D6; }

/* Filtros */
.filter { 
  display: flex; 
  gap: 0.625rem; 
  margin: 1rem 0; 
  flex-wrap: wrap; 
  align-items: center; 
}

/* Tabelas */
table { 
  width: 100%; 
  border-collapse: collapse; 
  margin-top: 1rem; 
  font-size: 0.9rem; 
}
th, td { 
  padding: 0.75rem; 
  text-align: center; 
  border-bottom: 1px solid var(--border); 
}
th { 
  background: var(--light); 
  font-weight: 600; 
  color: var(--gray); 
  cursor: pointer;
  transition: background 0.2s;
}
th:hover { background: var(--border); }
tr:hover { background: var(--light); }

/* Foto na Tabela */
td img.thumbnail {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: transform 0.2s;
}
td img.thumbnail:hover {
  transform: scale(1.1);
}

/* Cards */
.card { 
  background: var(--light); 
  border: 1px solid var(--border); 
  border-radius: 8px; 
  padding: 0.75rem; 
  margin: 0.5rem 0; 
}
.card h3 { margin-bottom: 0.5rem; font-size: 1.1rem; }

/* Dashboard Charts */
#dashboard .card {
  margin-bottom: 1.5rem;
}
canvas {
  background: var(--chart-bg);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 12px var(--shadow);
}

/* Modal (Foto e QR) */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  animation: fadeIn 0.3s;
}
.modal.active { display: flex; align-items: center; justify-content: center; }
.modal-content {
  background: var(--bg);
  padding: 1.5rem;
  border-radius: 16px;
  max-width: 90%;
  max-height: 90%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}
.modal-content img,  modal-content #qrCanvas {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
}
.close-modal {
  position: absolute;
  top: 10px; right: 15px;
  font-size: 1.8rem;
  color: var(--text);
  cursor: pointer;
  background: var(--light);
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* Câmera Preview */
#cameraPreview {
  width: 100%;
  max-width: 300px;
  height: auto;
  border-radius: 8px;
  margin-top: 0.5rem;
  border: 2px dashed var(--border);
}

/* Sync Status */
#syncStatus {
  font-weight: 600;
}
#syncStatus.online { color: var(--success); }
#syncStatus.offline { color: var(--warning); }
#syncStatus.error { color: var(--danger); }

/* Loading Spinner */
#loadingSpinner {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255,255,255,0.9);
  z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--primary);
}
.spinner {
  width: 50px; height: 50px;
  border: 5px solid var(--light);
  border-top: 5px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

/* Dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-content {
  display: none;
  position: absolute;
  background: var(--bg);
  min-width: 140px;
  box-shadow: 0 8px 16px var(--shadow);
  border-radius: 8px;
  z-index: 1;
  border: 1px solid var(--border);
  right: 0;
}
.dropdown-content button {
  width: 100%;
  background: none;
  color: var(--text);
  border: none;
  padding: 0.75rem 1rem;
  text-align: left;
  border-radius: 0;
}
.dropdown-content button:hover {
  background: var(--primary);
  color: white;
}
.dropdown:hover .dropdown-content { display: block; }

/* Toast */
.toast {
  position: fixed; 
  bottom: 20px; 
  right: 20px; 
  padding: 0.75rem 1.25rem; 
  border-radius: 8px;
  color: white; 
  font-weight: 600; 
  z-index: 1000; 
  animation: fadeIn 0.3s, fadeOut 0.3s 2.7s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

/* Login */
.login-card {
  padding: 2rem;
  text-align: center;
}
.login-card h1 {
  margin-bottom: 1.5rem;
  color: var(--primary);
}
.login-card input {
  width: 100%;
  margin-bottom: 1rem;
}
.login-card button {
  width: 100%;
}

/* Animações */
@keyframes fadeIn { 
  from { opacity: 0; transform: translateY(20px); } 
  to { opacity: 1; transform: translateY(0); } 
}
@keyframes fadeOut { 
  to { opacity: 0; transform: translateY(20px); } 
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Configurações */
.config {
  margin-bottom: 1rem;
}
.config label {
  display: block;
  margin-bottom: 0.5rem;
}
.config input, .config textarea {
  width: 100%;
  max-width: 300px;
}
#loadFeriadosBtn {
  margin-top: 0.5rem;
  background: var(--success);
}

/* Responsividade */
@media (max-width: 768px) {
  body { padding: 8px; }
  .tabs { flex-direction: column; }
  .tab { padding: 1rem; border-bottom: 1px solid var(--border); border-left: 3px solid transparent; }
  .tab.active { border-left-color: var(--primary); border-bottom-color: var(--border); }
  .form-grid { grid-template-columns: 1fr; }
  .filter { flex-direction: column; align-items: stretch; }
  .header-content { flex-direction: column; align-items: flex-start; }
  canvas { height: 250px !important; }
}

/* Impressão */
@media print { 
  .tabs, .filter, button, .theme-toggle, .dropdown, #appHeader, .modal { display: none !important; } 
  .tab-content { display: block !important; }
  body { background: white !important; color: black !important; }
  canvas { display: none; }
}