* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f5f6f8;
  color: #1f2430;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Spinner e Overlay de Carregamento */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #e0e2e7;
  border-top-color: #2f6fed;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#loading-text {
  margin-top: 16px;
  font-weight: 500;
  color: #444;
}

.app-header {
  padding: 24px 32px 8px;
  text-align: center;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.8rem;
}

.subtitle {
  margin: 0;
  color: #666;
  font-size: 0.95rem;
}

.app-main {
  flex: 1;
  padding: 16px 32px 32px;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.btn {
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: #2f6fed;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-secondary {
  background-color: #e0e2e7;
  color: #333;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #d1d5db;
}

.btn-success {
  background-color: #21a366;
  color: white;
}

.btn-success:hover:not(:disabled) {
  opacity: 0.9;
}

.status-message {
  font-size: 0.9rem;
  color: #666;
  margin-left: auto;
}

/* Área de Trabalho e Dropzone */
.workspace {
  background: white;
  border: 2px dashed #d5d8de;
  border-radius: 10px;
  min-height: 320px;
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-content: flex-start;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.workspace.file-hover {
  border-color: #2f6fed;
  background-color: #f0f5ff;
}

.workspace-empty {
  margin: auto;
  text-align: center;
  color: #888;
  pointer-events: none;
}

.workspace-empty p {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0 0 4px;
}

.workspace-empty span {
  font-size: 0.85rem;
  color: #aaa;
}

.app-footer {
  padding: 16px 32px 28px;
  display: flex;
  justify-content: center;
}

/* Painel de Compressão */
.compression-panel {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 32px 0;
}

.compression-panel h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: #333;
}

.compression-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.compression-row label {
  font-size: 0.9rem;
  color: #444;
  min-width: 160px;
}

.compression-row select,
.compression-row input {
  padding: 6px 10px;
  border: 1px solid #d5d8de;
  border-radius: 6px;
  font-size: 0.9rem;
}

.compression-row input[type="number"] {
  width: 120px;
}

.compression-hint {
  font-size: 0.78rem;
  color: #999;
  margin: 8px 0 0;
}

/* Métricas de Tamanho */
.size-metrics-container {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #d5d8de;
}

.metric-item {
  font-size: 0.85rem;
  color: #555;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-item strong {
  color: #1f2430;
}

.highlight-estimate {
  color: #2f6fed !important;
  font-weight: 600;
}

/* Cards das Páginas */
.page-card {
  position: relative;
  width: 135px;
  background: #fafafa;
  border: 1px solid #e0e2e7;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: grab;
  transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.page-card.dragging {
  opacity: 0.3;
}

.page-card.drag-over {
  border-color: #2f6fed;
  border-style: dashed;
  transform: scale(1.03);
}

.card-actions {
  position: absolute;
  top: -6px;
  right: -6px;
  display: flex;
  gap: 4px;
}

.btn-card-action {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid white;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  transition: transform 0.1s ease;
}

.btn-card-action:hover {
  transform: scale(1.15);
}

.btn-rotate {
  background-color: #2f6fed;
  color: white;
}

.btn-delete {
  background-color: #e63946;
  color: white;
}

.page-thumbnail-container {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 140px;
}

.page-thumbnail {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 1px solid #d5d8de;
  border-radius: 4px;
  background: white;
  pointer-events: none;
  transition: transform 0.2s ease;
}

.page-info {
  font-size: 0.7rem;
  color: #555;
  text-align: center;
  word-break: break-word;
  line-height: 1.2;
  pointer-events: none;
}

.logo {
  width: 80%;
  align-items: center;
  justify-content: center;
  margin: 12px auto 0;
}

.logo img {
  max-width: 20%;
  height: auto;
}

/* Navegação entre ferramentas */
.tool-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 4px 32px 0;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 500;
  color: #777;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover {
  color: #2f6fed;
}

.tab-btn.active {
  color: #2f6fed;
  border-bottom-color: #2f6fed;
}

.tool-view.hidden {
  display: none;
}

/* Ferramenta de conversão */
.convert-hint {
  max-width: 1000px;
  margin: 0 auto 10px;
  padding: 0 0;
  font-size: 0.85rem;
  color: #777;
}

.selection-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.btn-link {
  border: none;
  background: none;
  color: #2f6fed;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  opacity: 0.75;
}

.selection-count {
  font-size: 0.85rem;
  color: #666;
  margin-left: auto;
}

.convert-item-card {
  position: relative;
}

.convert-item-card.excluded {
  opacity: 0.4;
}

.item-checkbox {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  z-index: 2;
}

.file-icon-box {
  font-size: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.file-type-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(47, 111, 237, 0.9);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}