/* ==========================================================================
   SISTEMA DE DESIGN: DRIVE FÁCIL (TEMA CLEAN & LIGHT)
   ========================================================================== */

/* Variáveis e Paleta de Cores HSL Premium */
:root {
  --bg-app: #f8fafc;          /* Slate 50 - Fundo principal suave */
  --bg-card: #ffffff;         /* Branco puro para cartões e containers */
  --text-main: #334155;       /* Slate 700 - Texto de leitura e descrição */
  --text-dark: #0f172a;       /* Slate 900 - Títulos de alto contraste */
  --text-light: #64748b;      /* Slate 500 - Legendas e rodapés */
  
  --primary: #2563eb;         /* Blue 600 - Cor primária para foco e botões */
  --primary-hover: #1d4ed8;   /* Blue 700 - Hover do botão primária */
  --primary-light: #eff6ff;   /* Blue 50 - Fundo de notificações */
  
  --success: #16a34a;         /* Green 600 - Confirmações e status online */
  --success-light: #f0fdf4;   /* Green 50 - Selo de sucesso */
  --success-border: #bbf7d0;  /* Green 200 - Borda de sucesso */
  
  --danger: #ef4444;          /* Red 500 - Sair, exclusão, erros */
  --danger-hover: #dc2626;    /* Red 600 - Hover do perigo */
  --danger-light: #fef2f2;    /* Red 50 - Erros críticos */
  
  --border: #e2e8f0;          /* Slate 200 - Bordas sutis */
  --border-focus: #cbd5e1;    /* Slate 300 - Foco de inputs e bordas secundárias */
  
  /* Sombras projetadas de profundidade física e refinamento */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Classes Utilitárias */
.hidden {
  display: none !important;
}

/* Container de Transição SPA */
.app-container {
  width: 100%;
  max-width: 800px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ==========================================================================
   COMPONENTES DE AUTENTICAÇÃO (LOGIN E 2FA)
   ========================================================================== */

.auth-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.4s ease-out;
}

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

.logo-badge {
  background-color: var(--primary);
  color: #ffffff;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 auto 1.25rem auto;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.logo-badge.secure {
  background-color: var(--success);
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.25);
}

.auth-header h1 {
  color: var(--text-dark);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-light);
  font-size: 0.95rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  color: var(--text-dark);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-dark);
  background-color: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

/* Estilo do Input 2FA Código Especial */
#tfa-code {
  font-size: 1.75rem;
  letter-spacing: 0.35em;
  text-align: center;
  padding: 0.5rem;
  font-weight: 700;
}

#tfa-code::placeholder {
  letter-spacing: normal;
  font-size: 1rem;
  font-weight: 400;
}

/* Botões */
.btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
}

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

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

.btn-secondary {
  background-color: var(--bg-app);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: #ffffff;
  border-color: var(--border-focus);
}

.btn-danger {
  background-color: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

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

/* Links em Texto */
.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-text:hover:not(.disabled) {
  color: var(--primary-hover);
  text-decoration: underline;
}

.btn-text.disabled {
  color: var(--text-light);
  cursor: not-allowed;
}

/* Alertas e Caixas de Informação */
.alert-box {
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.85rem;
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  line-height: 1.4;
}

.info-box {
  background-color: var(--primary-light);
  border: 1px solid rgba(37, 99, 235, 0.1);
  color: #1e3a8a;
}

.alert-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* 2FA Alternativas & Reenviar */
.tfa-alternatives {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

/* Configuração do QR Code (TOTP Setup Box) */
.setup-trigger-container {
  text-align: center;
  margin-top: 1.25rem;
}

.setup-box {
  margin-top: 1.5rem;
  border-top: 1px dashed var(--border);
  padding-top: 1.5rem;
  animation: slideDown 0.3s ease-out;
}

.setup-box h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.setup-box p {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.setup-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.setup-input-row input {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  flex: 1;
}

.setup-input-row button {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  gap: 1rem;
}

#setup-qrcode-img img {
  width: 140px;
  height: 140px;
  border: 4px solid white;
  border-radius: 4px;
}

.qr-details {
  font-size: 0.75rem;
  color: var(--text-main);
  text-align: left;
  width: 100%;
}

.qr-details p {
  margin-bottom: 0.5rem;
}

#setup-raw-secret {
  display: block;
  font-family: monospace;
  font-size: 0.9rem;
  font-weight: 700;
  background-color: #ffffff;
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--primary);
  letter-spacing: 0.05em;
  margin: 0.5rem 0;
}

.warning-text {
  color: var(--danger) !important;
  font-weight: 600;
}

/* ==========================================================================
   PAINEL PRINCIPAL (DASHBOARD)
   ========================================================================== */

.dashboard-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.4s ease-out;
  overflow: hidden;
}

/* Header do Dashboard */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background-color: #ffffff;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-badge.mini {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  margin: 0;
}

.header-brand h2 {
  color: var(--text-dark);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

.header-brand .subtitle {
  font-size: 0.8rem;
}

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

/* Selo de Conexão Drive */
.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  transition: var(--transition);
}

.status-badge.connected {
  color: var(--success);
  background-color: var(--success-light);
  border: 1px solid var(--success-border);
}

.status-badge.disconnected {
  color: var(--danger);
  background-color: var(--danger-light);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-badge.connected .status-dot {
  background-color: var(--success);
}

.status-badge.disconnected .status-dot {
  background-color: var(--danger);
  animation: pulseRed 1.5s infinite;
}

/* Conteúdo do Dashboard */
.dashboard-main {
  padding: 2.5rem 2rem;
}

/* Zona de Drag & Drop */
.drop-zone {
  border: 2px dashed var(--border-focus);
  background-color: var(--bg-app);
  border-radius: var(--radius-lg);
  padding: 4rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background-color: var(--primary-light);
  box-shadow: inset 0 0 8px rgba(37, 99, 235, 0.04);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none; /* Garante que eventos de drag-drop peguem apenas a caixa pai */
}

.upload-icon {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 1.25rem;
  transition: var(--transition);
}

.drop-zone:hover .upload-icon,
.drop-zone.dragover .upload-icon {
  transform: translateY(-4px) scale(1.05);
}

.drop-zone h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
}

.drop-zone p {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.file-limits {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* Lista de Envio / Fila de arquivos */
.upload-list-container {
  margin-top: 2.5rem;
  border-top: 1px solid var(--border);
  padding-top: 2rem;
  animation: fadeIn 0.3s ease-out;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.list-header h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
}

.list-progress-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
}

.progress-bar-container {
  background-color: var(--border);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.progress-bar-container.mini {
  width: 100px;
  height: 8px;
}

.progress-bar {
  background-color: var(--primary);
  height: 100%;
  border-radius: 9999px;
  width: 0%;
  transition: width 0.3s ease-out;
}

.progress-bar.success {
  background-color: var(--success);
}

/* Fila de Cards de Arquivos */
.upload-files-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Scrollbar Personalizada Slim */
.upload-files-list::-webkit-scrollbar {
  width: 6px;
}
.upload-files-list::-webkit-scrollbar-track {
  background: transparent;
}
.upload-files-list::-webkit-scrollbar-thumb {
  background: var(--border-focus);
  border-radius: 3px;
}
.upload-files-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* Card do arquivo individual */
.file-card {
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  animation: slideDown 0.25s ease-out;
}

.file-card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.file-type-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
}

.file-metadata {
  flex: 1;
}

.file-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.35rem;
  word-break: break-all;
}

.file-progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.progress-bar-container.wide {
  width: 100%;
  max-width: 280px;
  height: 6px;
}

.progress-percentage {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  min-width: 32px;
}

.progress-percentage.success {
  color: var(--success);
}

/* Status do Arquivo */
.file-status {
  padding-left: 1rem;
  display: flex;
  align-items: center;
}

.status-checkmark {
  color: var(--success);
  font-size: 1.15rem;
  font-weight: 700;
}

.status-loader {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--primary);
  animation: pulse 1.5s infinite;
}

.status-error {
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Rodapé do Dashboard */
.dashboard-footer {
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--border);
  background-color: var(--bg-app);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ==========================================================================
   ANIMAÇÕES E SPINNER
   ========================================================================== */

/* Elemento Spinner Carregando */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.btn-secondary .spinner {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--text-main);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

@keyframes pulseRed {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ==========================================================================
   LISTAGEM E DOWNLOAD DE ARQUIVOS DO DRIVE (MODO EXPLORADOR DE ARQUIVOS)
   ========================================================================== */

.drive-files-container {
  margin-top: 2.5rem;
  border-top: 1px solid var(--border);
  padding-top: 2rem;
  animation: fadeIn 0.3s ease-out;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin-top: 1rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.file-explorer-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-main);
  background-color: #ffffff;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.file-explorer-table thead tr {
  background-color: #fafafa;
  border-bottom: 1px solid var(--border);
}

.file-explorer-table th {
  padding: 0.65rem 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
  user-select: none;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-right: 1px solid #e2e8f0;
  position: relative;
}

.file-explorer-table th:last-child {
  border-right: none;
}

.file-explorer-table th.sortable {
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.file-explorer-table th.sortable:hover {
  color: var(--primary);
  background-color: #f1f5f9;
}

.file-explorer-table th.active {
  color: var(--primary);
  background-color: #edf2f7;
}

.file-explorer-table td {
  padding: 0.65rem 0.85rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid rgba(241, 245, 249, 0.5);
  font-size: 0.82rem;
}

.file-explorer-table td:last-child {
  border-right: none;
}

.file-explorer-table tbody tr {
  transition: background-color 0.15s ease;
}

.file-explorer-table tbody tr:hover {
  background-color: rgba(37, 99, 235, 0.03); /* realce azul sutil no hover */
}

.file-explorer-table .file-name-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 500;
  color: var(--text-dark);
  word-break: break-all;
}

.file-explorer-table .file-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.sort-icon {
  font-size: 0.75rem;
  margin-left: 0.25rem;
  color: var(--text-light);
  display: inline-block;
  transition: transform 0.2s ease;
}

.active .sort-icon {
  color: var(--primary);
  font-weight: 700;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinning {
  animation: spin 0.8s linear infinite !important;
}

/* Customizações de botões pequenos */
.btn-small {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.loading-files,
.empty-files {
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  padding: 2.5rem;
}

/* Botão de download circular e clean */
.download-btn {
  background-color: var(--primary-light);
  color: var(--primary);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  border: 1px solid rgba(37, 99, 235, 0.1);
}

.download-btn:hover {
  background-color: var(--primary);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.15);
}
