:root {
  --bg-color: #0e1117;
  --card-bg: #262730;
  --text-color: #fafafa;
  --accent-color: #4facfe;
  --accent-hover: #00e1ecd3;
  --secondary-text: #a3a8b8;
  --highlight-blue: #b1edfc;
  --font-family: "Inter", sans-serif;
  --radius: 12px;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-family);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  max-width: 700px;
  /* Streamlit "centered" layout width approx */
  margin: 0 auto;
  padding: 2rem 1rem 80px 1rem;
  /* Bottom padding for footer */
  flex: 1;
}

/* Typography */
h1,
h2,
h3 {
  font-weight: 700;
}

.gradient-text {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  text-align: center;
  color: var(--secondary-text);
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

/* Features Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 3rem;
}

.feature-card {
  background-color: var(--card-bg);
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
  transition: transform 0.2s;
}

.feature-card:hover {
  transform: translateY(-5px);
}

.feature-card .icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.feature-card h3 {
  font-size: 0.9rem;
  color: var(--highlight-blue);
}

/* Upload Section */
.upload-section {
  text-align: center;
  background-color: transparent;
  border: 2px dashed #444;
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  transition: border-color 0.3s;
}

.upload-section:hover,
.upload-section.dragover {
  border-color: var(--accent-color);
}

.file-drop-area {
  position: relative;
  cursor: pointer;
  padding: 1rem;
}

.file-input {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  cursor: pointer;
  opacity: 0;
}

.fake-btn {
  background-color: #333;
  padding: 8px 16px;
  border-radius: 6px;
  margin-right: 8px;
  font-size: 0.9rem;
}

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

.file-info {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #333;
  padding: 5px 15px;
  border-radius: 20px;
  display: inline-flex;
}

.icon-btn {
  background: none;
  border: none;
  color: #ff6b6b;
  cursor: pointer;
  font-size: 1rem;
}

.primary-btn {
  margin-top: 1.5rem;
  background-color: var(--accent-color);
  color: white;
  border: none;
  padding: 12px 30px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  width: 100%;
  max-width: 300px;
}

.camera-btn {
  display: none;
  /* Hidden by default on desktop */
  margin-top: 1rem;
  background-color: transparent;
  border: 2px solid var(--accent-color);
  color: var(--accent-color);
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  width: 100%;
  max-width: 300px;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.camera-btn:hover {
  background-color: rgba(79, 172, 254, 0.1);
  transform: translateY(-2px);
}

/* Show camera button on mobile/tablet (using coarse pointer or screen size as proxy) */
@media (max-width: 1024px),
(pointer: coarse) {
  .camera-btn.mobile-only {
    display: inline-flex;
  }
}

.primary-btn:hover:not(:disabled) {
  background-color: var(--accent-hover);
  transform: scale(1.02);
}

.primary-btn:disabled {
  background-color: #444;
  cursor: not-allowed;
  opacity: 0.7;
}

.disclaimer-text {
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--secondary-text);
  font-style: italic;
  text-align: center;
}

/* Results */
.hidden {
  display: none !important;
}

.results-section {
  background-color: var(--card-bg);
  padding: 2rem;
  border-radius: var(--radius);
  margin-top: 2rem;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.section-title {
  color: var(--highlight-blue);
}

.close-btn {
  background: none;
  border: none;
  color: var(--secondary-text);
  font-size: 1.2rem;
  cursor: pointer;
}

.close-btn:hover {
  color: white;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.export-btn {
  background-color: transparent;
  border: 1.5px solid var(--accent-color);
  color: var(--accent-color);
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.export-btn:hover {
  background-color: rgba(79, 172, 254, 0.15);
  transform: translateY(-1px);
}

.score-container {
  margin-bottom: 1rem;
}

.score-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-color);
  margin-left: 10px;
}

.divider {
  height: 1px;
  background-color: #444;
  margin: 1.5rem 0;
}

/* Markdown Styles */
.markdown-body {
  color: var(--text-color);
  font-size: 1rem;
}

.markdown-body h2 {
  color: var(--highlight-blue);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.markdown-body h3,
.markdown-body strong {
  color: #e0e0e0;
}

.markdown-body ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-body li {
  margin-bottom: 0.5rem;
}

.markdown-body p {
  margin-bottom: 1rem;
}

/* Footer */
.custom-footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
  color: var(--secondary-text);
  border-top: 1px solid #262730;
  background-color: var(--bg-color);
}

.custom-footer a {
  color: var(--text-color);
  text-decoration: none;
}

.custom-footer a:hover {
  color: var(--accent-color);
}

/* Spinner */
.loading {
  text-align: center;
  margin-top: 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #444;
  border-top: 4px solid var(--accent-color);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Help Button */
.help-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, background-color 0.2s;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-btn:hover {
  background-color: var(--accent-hover);
  transform: scale(1.1);
}

/* Modal */
.modal {
  position: fixed;
  z-index: 1001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
}

.modal-content {
  background-color: var(--card-bg);
  padding: 2rem;
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.close-modal {
  color: var(--secondary-text);
  float: right;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
}

.close-modal:hover {
  color: white;
}

.modal-body {
  margin-top: 1rem;
  color: var(--text-color);
  line-height: 1.6;
}

.modal-body ul {
  padding-left: 1.2rem;
  margin: 1rem 0;
}

.modal-body li {
  margin-bottom: 0.5rem;
}

/* Responsive */
@media (max-width: 600px) {
  .features-grid {
    grid-template-columns: repeat(3, 1fr);
    /* Horizontal layout */
    gap: 0.5rem;
  }

  .feature-card {
    padding: 0.5rem;
  }

  .feature-card .icon {
    font-size: 1.2rem;
  }

  .feature-card h3 {
    font-size: 0.75rem;
  }
}

/* Print Styles */
@media print {

  /* Hide everything by default */
  body * {
    visibility: hidden;
  }

  /* Reset body background */
  body {
    background-color: white !important;
    color: black !important;
  }

  /* Show only the Results Section and its children */
  #resultsSection,
  #resultsSection * {
    visibility: visible;
  }

  /* Position Results Section to fill the page */
  #resultsSection {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0 !important;
    padding: 20px !important;
    background-color: white !important;
    box-shadow: none !important;
    border: none !important;
  }

  /* Hide the Action Buttons and Section Title inside Results Header */
  .header-actions,
  .section-title {
    display: none !important;
  }

  /* Ensure text is black and sharp */
  .markdown-body,
  .markdown-body p,
  .markdown-body li,
  .markdown-body strong,
  .markdown-body h1,
  .markdown-body h2,
  .markdown-body h3,
  .markdown-body td,
  .markdown-body th,
  .markdown-body pre,
  .markdown-body code {
    color: black !important;
    text-shadow: none !important;
  }

  /* Improve Score visibility in print */
  .score-container {
    border: 1px solid #ccc !important;
    background-color: #f9f9f9 !important;
    color: black !important;
    box-shadow: none !important;
  }

  .score-label,
  .score-value {
    color: black !important;
  }

  /* Hide Footer and other floating elements if any remain */
  .custom-footer,
  .help-btn,
  .hero,
  .features-grid,
  .upload-section,
  .disclaimer-text {
    display: none !important;
  }

  /* Add a print-only header */
  #resultsSection::before {
    content: "Easy Contract - Report Analisi";
    visibility: visible;
    display: block;
    font-size: 20px;
    font-weight: bold;
    color: #1a56db;
    border-bottom: 2px solid #1a56db;
    margin-bottom: 20px;
    padding-bottom: 10px;
  }
}