/* Main Styles for Physics Book Website */
:root {
  --primary-color: #3498db;
  --secondary-color: #2c3e50;
  --accent-color: #e74c3c;
  --light-color: #ecf0f1;
  --dark-color: #2c3e50;
  --text-color: #333;
  --link-color: #3498db;
  --link-hover-color: #2980b9;
  --header-height: 60px;
  --sidebar-width: 250px;
  --content-max-width: 1200px;
}

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

body {
  font-family: 'Roboto', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--light-color);
  overflow-x: hidden; /* Prevent horizontal scroll on mobile */
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: var(--link-hover-color);
}

.container {
  display: flex;
  min-height: 100vh;
}

/* Header Styles */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--secondary-color);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  margin-right: 15px;
}

/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--dark-color);
  color: white;
  padding: 20px;
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  transition: transform 0.3s ease, width 0.3s ease;
  z-index: 900;
}

.sidebar h3 {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar ul {
  list-style: none;
}

.sidebar li {
  margin-bottom: 10px;
}

.sidebar a {
  color: white;
  display: block;
  padding: 8px 10px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.sidebar a:hover, .sidebar a.active {
  background-color: rgba(255,255,255,0.1);
}

/* Main Content Styles */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 30px;
  max-width: calc(100% - var(--sidebar-width));
  transition: margin-left 0.3s ease, max-width 0.3s ease;
}

.content-wrapper {
  max-width: var(--content-max-width);
  margin: 0 auto;
  background-color: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Mind Map Section */
.mind-map-container {
  text-align: center;
  margin-bottom: 30px;
}

.mind-map-container img {
  max-width: 100%;
  height: auto;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* Mind Map Preview */
.mind-map-preview {
  position: relative;
  margin: 20px 0;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.mind-map-preview img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.mind-map-preview .overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mind-map-preview:hover .overlay {
  opacity: 1;
}

.mind-map-preview .overlay span {
  color: white;
  background-color: var(--primary-color);
  padding: 10px 20px;
  border-radius: 4px;
  font-weight: bold;
}

.mind-map-preview:hover img {
  transform: scale(1.05);
}

/* Chapter Sections */
.chapter-section {
  margin-bottom: 40px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.chapter-section:first-of-type {
  border-top: none;
}

.chapter-section h2 {
  color: var(--secondary-color);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-color);
}

/* Chapter Preview */
.chapter-preview {
  background-color: #f9f9f9;
  padding: 20px;
  border-radius: 8px;
  margin: 20px 0;
}

.chapter-preview h3 {
  color: var(--secondary-color);
  margin-bottom: 15px;
}

.chapter-preview ul {
  margin-left: 20px;
  margin-bottom: 20px;
}

.view-chapter-btn {
  display: inline-block;
  background-color: var(--primary-color);
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  font-weight: bold;
  transition: background-color 0.3s ease;
}

.view-chapter-btn:hover {
  background-color: var(--link-hover-color);
  color: white;
}

/* Chapter Navigation */
.chapter-navigation {
  display: flex;
  justify-content: space-between;
  margin-top: 30px;
}

.nav-prev, .nav-next {
  background-color: var(--secondary-color);
  color: white;
  padding: 8px 15px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.nav-prev:hover, .nav-next:hover {
  background-color: var(--dark-color);
  color: white;
}

/* Welcome Section */
#welcome {
  margin-bottom: 40px;
}

.features {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 30px;
}

.feature {
  flex: 1;
  min-width: 250px;
  background-color: #f9f9f9;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.feature h3 {
  color: var(--primary-color);
  margin-bottom: 10px;
}

/* Formula Styling */
.formula {
  font-family: 'Cambria Math', Georgia, serif;
  background-color: #f9f9f9;
  padding: 10px;
  border-radius: 4px;
  margin: 10px 0;
  overflow-x: auto;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

th, td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

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

tr:hover {
  background-color: #f5f5f5;
}

/* Topic Sections */
.topic-section {
  margin-bottom: 30px;
}

.topic-section h2 {
  color: var(--secondary-color);
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ddd;
}

.topic-section h3 {
  color: var(--primary-color);
  margin-bottom: 15px;
}

.subtopic {
  margin-left: 20px;
  margin-bottom: 20px;
}

.subtopic h4 {
  color: var(--secondary-color);
  margin-bottom: 10px;
}

.key-points {
  background-color: #f8f9fa;
  border-left: 4px solid var(--primary-color);
  padding: 15px;
  margin: 15px 0;
}

.key-points h4 {
  margin-bottom: 10px;
  color: var(--primary-color);
}

.key-points ul {
  margin-left: 20px;
}

/* Code blocks for formulas */
pre {
  background-color: #f5f5f5;
  padding: 15px;
  border-radius: 4px;
  overflow-x: auto;
  font-family: 'Courier New', monospace;
}

/* Highlight important concepts */
.important {
  font-weight: bold;
  color: var(--accent-color);
}

/* Back to top button */
.back-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: var(--primary-color);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 800;
}

.back-to-top.visible {
  opacity: 1;
}

/* Search box styling */
.search-container {
  margin-left: auto;
  position: relative;
}

.search-box {
  padding: 8px 12px;
  border-radius: 20px;
  border: none;
  outline: none;
  width: 200px;
  transition: width 0.3s ease;
}

.search-results {
  position: absolute;
  top: 100%;
  right: 0;
  width: 300px;
  background-color: white;
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 1100;
}

.search-results.active {
  display: block;
}

.search-result-item {
  padding: 10px 15px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  display: block;
}

.search-result-item:hover {
  background-color: #f5f5f5;
}

.result-title {
  font-weight: bold;
  color: var(--secondary-color);
}

.result-section {
  font-size: 0.85rem;
  color: #666;
}

.no-results {
  padding: 15px;
  text-align: center;
  color: #666;
}

/* Enhanced Responsive Design */
@media (max-width: 992px) {
  .content-wrapper {
    padding: 25px;
  }
  
  .features {
    flex-direction: column;
  }
  
  .feature {
    min-width: 100%;
  }
}

@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }
  
  .sidebar {
    transform: translateX(-100%);
    width: 80%;
    max-width: 300px;
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    max-width: 100%;
    padding: 20px;
  }
  
  .content-wrapper {
    padding: 20px;
  }
  
  .search-box {
    width: 150px;
  }
  
  .search-results {
    width: 250px;
    right: -20px;
  }
  
  .chapter-navigation {
    flex-direction: column;
    gap: 10px;
  }
  
  .nav-prev, .nav-next {
    text-align: center;
  }
  
  /* Add overlay when sidebar is active */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 800;
  }
  
  .sidebar-overlay.active {
    display: block;
  }
}

@media (max-width: 480px) {
  .logo {
    font-size: 1.2rem;
  }
  
  .search-box {
    width: 120px;
  }
  
  .search-results {
    width: 220px;
  }
  
  .content-wrapper {
    padding: 15px;
  }
  
  h1 {
    font-size: 1.8rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  .chapter-preview {
    padding: 15px;
  }
  
  .view-chapter-btn {
    display: block;
    text-align: center;
  }
  
  /* Adjust formula display for small screens */
  .formula {
    font-size: 0.9rem;
  }
  
  /* Make tables responsive */
  table {
    display: block;
    overflow-x: auto;
  }
}

/* Touch-friendly adjustments */
@media (hover: none) {
  .sidebar a {
    padding: 12px 10px; /* Larger touch targets */
  }
  
  .back-to-top {
    width: 50px;
    height: 50px;
  }
  
  .view-chapter-btn {
    padding: 12px 20px;
  }
  
  .nav-prev, .nav-next {
    padding: 12px 15px;
  }
  
  /* Always show back to top on touch devices */
  .back-to-top {
    opacity: 0.8;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --light-color: #1a1a1a;
    --text-color: #f0f0f0;
  }
  
  .content-wrapper {
    background-color: #2a2a2a;
    color: #f0f0f0;
  }
  
  .chapter-preview, .feature, .key-points, .formula, pre {
    background-color: #333;
  }
  
  .search-box {
    background-color: #333;
    color: #f0f0f0;
  }
  
  .search-results {
    background-color: #2a2a2a;
  }
  
  .search-result-item {
    border-bottom-color: #444;
  }
  
  .search-result-item:hover {
    background-color: #3a3a3a;
  }
  
  .result-title {
    color: var(--primary-color);
  }
  
  .result-section {
    color: #aaa;
  }
  
  table th {
    background-color: #444;
  }
  
  table td {
    border-bottom-color: #444;
  }
  
  tr:hover {
    background-color: #3a3a3a;
  }
}

/* Print Styles */
@media print {
  header, .sidebar, .nav-toggle, .back-to-top {
    display: none;
  }
  
  .main-content {
    margin: 0;
    max-width: 100%;
    padding: 0;
  }
  
  .content-wrapper {
    box-shadow: none;
    padding: 0;
  }
  
  .chapter-navigation {
    display: none;
  }
  
  a {
    color: #000;
    text-decoration: none;
  }
  
  .chapter-section {
    page-break-after: always;
  }
  
  .formula, .key-points {
    page-break-inside: avoid;
  }
}
