/* Hebrew Text Viewer - Styles inspired by Dicta.org.il */

:root {
  /* Color and layout variables */
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --accent-color: #e74c3c;
  --success-color: #27ae60;
  --warning-color: #f39c12;
  --text-color: #2c3e50;
  --text-light: #7f8c8d;
  --bg-color: #ffffff;
  --bg-light: #f8f9fa;
  --border-color: #e1e8ed;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
  --border-radius: 8px;
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-color);
  line-height: 1.6;
  direction: ltr;
}

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

/* Header */
.header {
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
}

.navigation-controls {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.book-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.book-selector label {
  font-weight: 500;
  color: var(--text-light);
}

.book-dropdown {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-color);
  font-size: 1rem;
  min-width: 150px;
  transition: var(--transition);
}

.book-dropdown:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.chapter-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn {
  background: var(--secondary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.2rem;
}

.nav-btn:hover:not(:disabled) {
  background: #2980b9;
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.nav-btn:disabled {
  background: var(--text-light);
  cursor: not-allowed;
  opacity: 0.5;
}

.chapter-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 1rem;
}

.chapter-label {
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 500;
}

.chapter-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

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

.text-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2rem;
  min-height: 600px;
}

.text-panel {
  background: var(--bg-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  background: var(--primary-color);
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.verse-count {
  font-size: 0.9rem;
  opacity: 0.8;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

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

.edit-btn:hover {
  background: #2980b9;
}

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

.save-btn:hover {
  background: #229954;
}

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

.cancel-btn:hover {
  background: #c0392b;
}

.text-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 70vh;
}

.verse {
  margin-bottom: 1.5rem;
  padding: 1rem;
  border-radius: var(--border-radius);
  background: var(--bg-light);
  border-left: 4px solid var(--secondary-color);
  transition: var(--transition);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.verse:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.verse-number {
  display: inline-block;
  background: var(--secondary-color);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-right: 0.75rem;
  min-width: 30px;
  text-align: center;
}

.verse-text {
  font-family: 'Noto Sans Hebrew', 'Times New Roman', serif;
  font-size: 1.1rem;
  line-height: 1.8;
  word-spacing: 0.1em;
  flex: 1;
  display: flex;
  align-items: flex-start;
}

/* Editable states */
.verse-text.editable {
  cursor: text;
  padding: 0.5rem;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: var(--transition);
}

.verse-text.editable:hover {
  border-color: var(--border-color);
  background: rgba(52, 152, 219, 0.05);
}

.verse-text.editing {
  border-color: var(--secondary-color);
  background: rgba(52, 152, 219, 0.1);
  outline: none;
}

.no-content {
  text-align: center;
  color: var(--text-light);
  font-style: italic;
  padding: 3rem;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--secondary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  margin-top: 1rem;
  color: var(--text-light);
  font-weight: 500;
}

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

/* Responsive Layout */
@media (max-width: 1024px) {
  .text-container {
    grid-template-columns: 1fr;
  }
}

/* Audio Controls */
.audio-verse {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.audio-verse:last-child {
  border-bottom: none;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.audio-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  margin-right: 8px;
}

.audio-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.pause-btn {
  background: var(--warning-color);
}

.pause-btn:hover {
  background: #e67e22;
}

.stop-btn {
  background: var(--danger-color);
}

.stop-btn:hover {
  background: #c0392b;
}

.audio-info {
  flex: 1;
  min-width: 0;
}

.audio-filename {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: 'Courier New', monospace;
  word-break: break-all;
}

/* Responsive adjustments for three columns */
@media (max-width: 1200px) {
  .text-container {
    grid-template-columns: 1fr 1fr;
  }
  
  .text-panel:nth-child(3) {
    grid-column: 1 / -1;
    margin-top: 1rem;
  }
}

@media (max-width: 768px) {
  .text-container {
    grid-template-columns: 1fr;
  }
  
  .text-panel:nth-child(3) {
    grid-column: auto;
    margin-top: 0;
  }
}

/* Alignment Fixes */
.hebrew-text {
  direction: rtl;
  text-align: right;
}

.ipa-text {
  direction: ltr;
  text-align: left;
}

/* Password Modal Styles */
.password-form {
  margin: 20px 0;
}

.password-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.password-input:focus {
  outline: none;
  border-color: #4a90e2;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.password-input::placeholder {
  color: #9ca3af;
}

.error-message {
  color: #dc2626;
  font-size: 14px;
  margin-top: 8px;
  font-weight: 500;
}

/* Logout button styling */
.logout-btn {
  background-color: #6b7280;
  color: white;
  border: 1px solid #6b7280;
}

.logout-btn:hover {
  background-color: #4b5563;
  border-color: #4b5563;
}

/* IPA Toggle Button */
.ipa-toggle-btn {
  background-color: #10b981;
  color: white;
  border: 1px solid #10b981;
}

.ipa-toggle-btn:hover {
  background-color: #059669;
  border-color: #059669;
}

.ipa-toggle-btn.active {
  background-color: #dc2626;
  border-color: #dc2626;
}

.ipa-toggle-btn.active:hover {
  background-color: #b91c1c;
  border-color: #b91c1c;
}

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

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-content h3 {
  margin: 0 0 15px 0;
  color: #1f2937;
  font-size: 1.5rem;
  font-weight: 600;
}

.modal-content p {
  margin: 0 0 20px 0;
  color: #6b7280;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 25px;
}

.modal-actions .btn {
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: 14px;
}

.modal-actions .btn-primary {
  background-color: #4a90e2;
  color: white;
}

.modal-actions .btn-primary:hover {
  background-color: #357abd;
}

.modal-actions .btn-secondary {
  background-color: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.modal-actions .btn-secondary:hover {
  background-color: #e5e7eb;
}

/* IPA Keyboard Styles */
.ipa-keyboard {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 600px;
  max-width: 90vw;
  max-height: 70vh;
  background: white;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  z-index: 1001;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
}

.ipa-keyboard-header {
  background: #f8f9fa;
  padding: 12px 16px;
  border-bottom: 1px solid #e1e5e9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
  user-select: none;
}

.ipa-keyboard-header:active {
  cursor: grabbing;
}

.ipa-keyboard-header h4 {
  margin: 0;
  color: #1f2937;
  font-size: 16px;
  font-weight: 600;
}

.ipa-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.ipa-close-btn:hover {
  background-color: #e5e7eb;
  color: #374151;
}

.ipa-keyboard-content {
  padding: 16px;
  max-height: calc(70vh - 60px);
  overflow-y: auto;
}

.ipa-section {
  margin-bottom: 20px;
}

.ipa-section:last-child {
  margin-bottom: 0;
}

.ipa-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ipa-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.ipa-row:last-child {
  margin-bottom: 0;
}

.ipa-key {
  background: #f8f9fa;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 16px;
  font-weight: 500;
  color: #1f2937;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 40px;
  text-align: center;
  position: relative;
  font-family: 'Inter', sans-serif;
}

.ipa-key:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.ipa-key:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.ipa-key::after {
  content: attr(data-name);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 1002;
  margin-bottom: 8px;
}

.ipa-key::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 1002;
  margin-bottom: 3px;
}

.ipa-key:hover::after,
.ipa-key:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .ipa-keyboard {
    bottom: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: 60vh;
  }
  
  .ipa-key {
    min-width: 35px;
    padding: 6px 10px;
    font-size: 14px;
  }
  
  .ipa-key::after {
    font-size: 11px;
    padding: 4px 8px;
  }
}

