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

:root {
  --primary: #667eea;
  --primary-dark: #5568d3;
  --secondary: #764ba2;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --bg-light: #f9fafb;
  --bg-white: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text-primary);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 1rem 0;
}

.header-content {
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.header-badge .badge {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
}

/* Main Content */
.main {
  padding: 1.5rem 0 2rem;
  min-height: calc(100vh - 88px);
  display: flex;
  align-items: stretch;
  width: 100%;
}

.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: stretch;
  width: 100%;
}

/* Duas colunas apenas para telas grandes em modo horizontal */
@media (min-width: 1024px) and (orientation: landscape) {
  .dashboard {
    grid-template-columns: 1.1fr 1fr;
    height: calc(100vh - 120px);
  }

  .dashboard .card {
    height: 100%;
  }

  #email_text {
    max-height: 45vh;
  }
}

.dashboard .card {
  height: 100%;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.dashboard .card-header {
  padding: 1.25rem 1.5rem 0.5rem;
  margin-bottom: 0.75rem;
}

.dashboard form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.dashboard .tab-content {
  flex: 1;
}

#email_text {
  min-height: 200px;
  height: 100%;
  max-height: 45vh;
}

.file-upload-area {
  min-height: 180px;
}

.hero {
  text-align: center;
  color: white;
  margin-bottom: 3rem;
}

.hero h2 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hero p {
  font-size: 1.125rem;
  opacity: 0.95;
  max-width: 600px;
  margin: 0 auto;
}

/* Card */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  margin-bottom: 2rem;
}

.card-header {
  margin-bottom: 2rem;
}

.card-header h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.card-header p {
  color: var(--text-secondary);
  font-size: 0.938rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}

.tab {
  background: none;
  border: none;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Form */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.938rem;
}

textarea {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.938rem;
  resize: vertical;
  transition: border-color 0.2s;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* File Upload */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.file-upload-area:hover {
  border-color: var(--primary);
  background: rgba(102, 126, 234, 0.02);
}

.file-upload-area svg {
  margin-bottom: 1rem;
  color: var(--primary);
}

.file-upload-area p {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.file-types {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.file-selected {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  border: 2px solid var(--primary);
}

.file-selected svg {
  color: var(--primary);
}

.file-selected span {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
}

.btn-remove {
  background: var(--danger);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-remove:hover {
  background: #dc2626;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #5B68FF, #8B3FFF);
  color: white;
  width: 100%;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(91, 104, 255, 0.25);
  font-size: 1.125rem;
  padding: 1.25rem 2rem;
  position: relative;
  animation: subtlePulse 2s ease-in-out infinite;
}

@keyframes subtlePulse {
  0%, 100% {
    box-shadow: 0 2px 12px rgba(91, 104, 255, 0.25);
  }
  50% {
    box-shadow: 0 4px 16px rgba(91, 104, 255, 0.35);
  }
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(91, 104, 255, 0.4);
  animation: none;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  animation: none;
}

.btn-secondary {
  background: var(--bg-light);
  color: var(--primary);
  border: 2px solid var(--border);
  width: 100%;
  justify-content: center;
}

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

/* Results */
.results-section {
  animation: fadeInUp 0.5s ease;
  position: relative;
}

.results-section .card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  padding: 1.5rem;
  gap: 1.5rem;
}

.results-section .card > .card-header {
  padding: 0;
  margin: 0;
  flex-shrink: 0;
}

.results-section .card > .results-grid {
  flex: 1;
  min-height: 0;
}

.results-section .card > .btn {
  flex-shrink: 0;
  align-self: flex-start;
  width: auto;
}

.results-section.is-empty .card {
  opacity: 0.4;
}

.results-section.has-results .results-empty {
  display: none;
}

.results-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  padding: 1rem;
  z-index: 1;
}

.results-empty h4 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.results-empty p {
  color: rgba(255, 255, 255, 0.75);
}

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

.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 0.5rem;
}

.results-grid::-webkit-scrollbar {
  width: 6px;
}

.results-grid::-webkit-scrollbar-track {
  background: transparent;
}

.results-grid::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.results-grid::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.result-card {
  padding: 1.5rem;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.result-header svg {
  color: var(--primary);
}

.result-header h4 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.classification-result {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.category-badge {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 1.125rem;
  text-align: center;
}

.category-badge:empty {
  display: none;
}

.category-badge.produtivo {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.category-badge.improdutivo {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

.confidence {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: white;
  border-radius: var(--radius-sm);
}

.confidence span {
  color: var(--text-secondary);
}

.confidence strong {
  color: var(--primary);
  font-size: 1.25rem;
}

/* Response Section */
.response-section {
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  margin-bottom: 0;
  border: 2px solid var(--border);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.response-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.response-header svg {
  color: var(--primary);
}

.response-header h4 {
  flex: 1;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-copy {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

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

.response-content {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  line-height: 1.8;
  color: var(--text-primary);
  border: 1px solid var(--border);
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

.loading-overlay p {
  color: white;
  font-size: 1.125rem;
  font-weight: 500;
}

/* Footer */
.footer {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  color: white;
  text-align: center;
  padding: 1.5rem 0;
  margin-top: 2rem;
}

.footer p {
  margin: 0;
  font-size: 0.938rem;
}

.footer a {
  color: white;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}

.footer a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 1023px) {
  .dashboard {
    height: auto;
  }

  .dashboard .card {
    height: auto;
  }

  #email_text {
    min-height: 150px;
    max-height: none;
  }

  .results-section {
    margin-top: 1rem;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 15px;
  }

  .header {
    padding: 0.75rem 0;
  }

  .logo {
    gap: 8px;
  }

  .logo h1 {
    font-size: 1.125rem;
  }

  .hero h2 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 0.938rem;
  }

  .card {
    padding: 1.25rem;
    margin-bottom: 1.5rem;
  }

  .card-header {
    margin-bottom: 1.5rem;
  }

  .card-header h3 {
    font-size: 1.25rem;
  }

  .dashboard .card-header {
    padding: 1rem 1.25rem 0.5rem;
  }

  .tabs {
    margin-bottom: 1rem;
    gap: 0.25rem;
  }

  .tab {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .form-group {
    margin-bottom: 1.25rem;
  }

  textarea {
    font-size: 16px;
  }

  .file-upload-area {
    padding: 2rem 1rem;
    min-height: 150px;
  }

  .file-upload-area svg {
    width: 32px;
    height: 32px;
  }

  .file-types {
    font-size: 0.8rem;
  }

  .btn {
    padding: 0.875rem 1.5rem;
    font-size: 0.938rem;
  }

  .result-header {
    gap: 0.5rem;
  }

  .result-header h4 {
    font-size: 1rem;
  }

  .category-badge {
    font-size: 1rem;
    padding: 0.625rem 1.25rem;
  }

  .response-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .response-header h4 {
    font-size: 1rem;
  }

  .btn-copy {
    align-self: flex-start;
  }

  .results-grid {
    gap: 1rem;
  }

  .result-card {
    padding: 1rem;
  }

  .response-section {
    padding: 1rem;
  }

  .response-content {
    padding: 1rem;
    font-size: 0.875rem;
  }

  .error-modal-content {
    width: 95%;
    max-width: none;
  }

  .error-modal-header {
    padding: 16px;
  }

  .error-modal-body {
    padding: 16px;
  }

  .error-modal-footer {
    padding: 12px 16px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }

  .header {
    padding: 0.5rem 0;
  }

  .logo {
    gap: 6px;
  }

  .logo h1 {
    font-size: 1rem;
  }

  .logo svg {
    width: 28px;
    height: 28px;
  }

  .hero h2 {
    font-size: 1.5rem;
  }

  .hero p {
    font-size: 0.875rem;
  }

  .card {
    padding: 1rem;
    border-radius: 8px;
  }

  .card-header h3 {
    font-size: 1.125rem;
  }

  .card-header p {
    font-size: 0.8rem;
  }

  .tabs {
    gap: 0;
    border-bottom: none;
    background: var(--bg-light);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
  }

  .tab {
    flex: 1;
    padding: 0.625rem 0.75rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0;
  }

  .tab.active {
    border-bottom-color: transparent;
    background: white;
    border: none;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  .form-group label {
    font-size: 0.8rem;
  }

  textarea {
    padding: 0.75rem;
    font-size: 16px;
    min-height: 120px;
  }

  .file-upload-area {
    padding: 1.5rem 1rem;
    min-height: 120px;
  }

  .file-upload-area svg {
    width: 28px;
    height: 28px;
    margin-bottom: 0.5rem;
  }

  .file-upload-area p {
    font-size: 0.875rem;
  }

  .file-types {
    font-size: 0.75rem;
  }

  .btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    width: 100%;
  }

  .btn-secondary {
    margin-top: 1rem;
  }

  .result-card {
    padding: 0.75rem;
  }

  .result-header svg {
    width: 20px;
    height: 20px;
  }

  .result-header h4 {
    font-size: 0.95rem;
  }

  .category-badge {
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    display: block;
    width: 100%;
  }

  .confidence {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .confidence strong {
    font-size: 1.125rem;
  }

  .response-section {
    padding: 0.75rem;
  }

  .response-header svg {
    width: 20px;
    height: 20px;
  }

  .response-content {
    padding: 0.75rem;
    font-size: 0.8rem;
    line-height: 1.6;
  }

  .btn-copy {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
  }

  .btn-copy svg {
    width: 14px;
    height: 14px;
  }

  .loading-overlay p {
    font-size: 1rem;
    padding: 0 1rem;
  }

  .spinner {
    width: 40px;
    height: 40px;
  }

  .error-modal-content {
    width: 90%;
  }

  .error-modal-header {
    padding: 12px;
    font-size: 0.95rem;
  }

  .error-modal-header svg {
    width: 20px;
    height: 20px;
  }

  .error-modal-body {
    padding: 12px;
    font-size: 0.875rem;
  }

  .error-modal-footer {
    padding: 10px 12px;
  }

  .error-modal-btn {
    padding: 6px 16px;
    font-size: 0.
  .tab {
    padding: 0.75rem 1rem;
    font-size: 0.938rem;
  }
}

/* Modal de Erro */
#errorModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.error-modal-content {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 400px;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}

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

.error-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  color: var(--danger);
  font-weight: 600;
}

.error-modal-header svg {
  flex-shrink: 0;
}

.error-modal-body {
  padding: 20px;
  color: var(--text-primary);
}

.error-modal-body p {
  line-height: 1.6;
}

.error-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

.error-modal-btn {
  padding: 8px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.938rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.error-modal-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.error-modal-btn:active {
  transform: translateY(0);
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.mt-2 {
  margin-top: 1rem;
}

.mb-2 {
  margin-bottom: 1rem;
}
