/* Base styles and CSS variables */
:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --secondary: #475569;
  --secondary-hover: #334155;
  --success: #059669;
  --success-hover: #047857;
  --error: #dc2626;
  --error-hover: #b91c1c;
  --background: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navigation */
.top-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-link {
  color: var(--text-light);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 0;
  position: relative;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: var(--primary);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

/* Main content */
.main-content {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* Page header */
.page-header {
  margin-bottom: 2.5rem;
  text-align: center;
}

.page-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

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

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.card-description {
  color: var(--text-light);
  font-size: 0.875rem;
}

.card-content {
  padding: 1.5rem;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.5rem;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

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

.upload-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.upload-text {
  color: var(--text-light);
  font-size: 0.875rem;
}

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

.input-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.input-wrapper {
  position: relative;
}

.text-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: var(--text);
  transition: all 0.2s;
}

.text-input:hover {
  border-color: var(--text-light);
}

.text-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.button-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-icon {
  font-size: 1.125rem;
}

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

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

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

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

.btn-full {
  width: 100%;
}

/* Result box */
.result-box {
  background: var(--background);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--text);
  min-height: 100px;
}

/* Footer */
.app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.875rem;
}

/* Responsive design */
@media (max-width: 768px) {
  .nav-content {
    flex-direction: column;
    gap: 1rem;
  }

  .page-header h1 {
    font-size: 2rem;
  }

  .button-group {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: 1.5rem 1rem;
  }

  .card-header, .card-content {
    padding: 1.25rem;
  }

  .upload-zone {
    padding: 1.5rem;
  }
}

/* Support form styles */
.support-form {
  margin-bottom: 1.5rem;
}

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

.support-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: var(--text);
  transition: all 0.2s;
  resize: vertical;
  min-height: 100px;
  margin-bottom: 1rem;
  font-family: inherit;
}

.support-input:hover {
  border-color: var(--text-light);
}

.support-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.support-submit {
  display: block;
  margin-left: auto;
  cursor: pointer;
  text-align: center;
  width: 120px;
}

.support-submit.disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Recent questions styles */
.recent-questions {
  height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 1rem;
  background-color: var(--surface);
}

.recent-questions h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text);
  position: sticky;
  top: 0;
  background-color: var(--surface);
  padding: 1rem 1rem 0.5rem;
  margin-top: 0;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

.recent-questions-content {
  padding: 0 1rem 1rem;
}

#loading-questions {
  text-align: center;
  color: var(--text-light);
  padding: 1rem;
  font-style: italic;
}

.no-questions {
  text-align: center;
  color: var(--text-light);
  padding: 1rem;
  font-style: italic;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-top: 1rem;
}

.question-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.question-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.question-author {
  font-weight: 600;
  color: var(--text);
}

.question-date {
  font-size: 0.875rem;
  color: var(--text-light);
}

.question-text {
  margin-bottom: 1rem;
}

.question-reply {
  background-color: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.question-reply p {
  margin: 0;
}

/* Custom scrollbar for recent questions */
.recent-questions::-webkit-scrollbar {
  width: 8px;
}

.recent-questions::-webkit-scrollbar-track {
  background-color: var(--background);
  border-radius: var(--radius);
}

.recent-questions::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: var(--radius);
}

.recent-questions::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-light);
}

/* Base responsive design */
@media screen and (max-width: 1200px) {
  .main-content {
    max-width: 100%;
    padding: 1.5rem;
  }

  .nav-content {
    padding: 0 1rem;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
  }
}

@media screen and (max-width: 992px) {
  .page-header h1 {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .card {
    margin: 0 auto;
    max-width: 600px;
  }
}

@media screen and (max-width: 768px) {
  .nav-content {
    padding: 0 1rem;
    flex-direction: column;
    gap: 1rem;
  }

  .page-header h1 {
    font-size: 1.75rem;
  }

  .button-group {
    flex-direction: column;
    gap: 0.75rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .upload-zone {
    padding: 1.5rem;
  }

  .support-form {
    padding: 1rem;
  }

  .support-input {
    min-height: 100px;
  }

  .table-of-contents {
    position: relative !important;
    top: 0 !important;
    width: 100% !important;
    margin-bottom: 1.5rem;
  }

  .policy-container {
    flex-direction: column !important;
  }

  .sidebar {
    position: relative !important;
    width: 100% !important;
  }

  .policy-content {
    padding: 1rem !important;
  }

  .permission-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media screen and (max-width: 480px) {
  .main-content {
    padding: 1rem;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .card-header, 
  .card-content {
    padding: 1rem;
  }

  .upload-zone {
    padding: 1rem;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  .input-group {
    flex-direction: column;
  }

  .text-input {
    width: 100%;
  }

  .policy-section {
    padding: 1rem !important;
  }

  .important-notice {
    padding: 0.75rem !important;
    margin: 0.75rem 0 !important;
  }

  .table-of-contents a {
    padding: 0.5rem !important;
  }
}

/* iPad specific adjustments */
@media screen and (min-width: 768px) and (max-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
  }

  .policy-container {
    gap: 1.5rem !important;
  }

  .sidebar {
    flex: 0 0 250px !important;
  }

  .table-of-contents {
    width: 250px !important;
  }
}

/* Landscape orientation adjustments */
@media screen and (max-height: 480px) and (orientation: landscape) {
  .table-of-contents {
    max-height: 80vh !important;
  }

  .upload-zone {
    padding: 1rem;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

/* Touch device optimizations */
@media (hover: none) {
  .card:hover {
    transform: none;
  }

  .btn:hover {
    transform: none;
  }

  .table-of-contents a:hover {
    transform: none !important;
  }
}

/* High-DPI screen adjustments */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .btn,
  .card,
  .input-group,
  .text-input {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Print media adjustments */
@media print {
  .top-nav,
  .app-footer,
  .support-form,
  .upload-zone {
    display: none !important;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .policy-content {
    font-size: 12pt;
  }
}
