/**
 * Flashy - Smart Flashcard Learning
 * Version: 0.8.0
 * Last Updated: 2025-07-01 19:30:51
 * Updated By: lyitu
 */

:root {
  /* Main color palette */
  --primary: #4361ee;
  --primary-dark: #3a56d4;
  --primary-light: #eef2ff;
  --secondary: #2ec4b6;
  --accent: #ff9f1c;
  --accent-light: #ffbf69;
  --danger: #e63946;
  --success: #2a9d8f;
  --warning: #f77f00;
  --dark: #212529;
  --medium: #495057;
  --light: #f8f9fa;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  
  /* Card colors */
  --card-bg: white;
  --card-border: #e9ecef;
  --editing-bg: #fff8e6;
  --editing-border: #ffe8b3;
  
  /* Font settings */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font-main);
  background-color: #f7f9fc;
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5em;
  color: var(--dark);
}

h1 {
  font-size: 2.25rem;
}

h2 {
  font-size: 1.85rem;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

h5 {
  font-size: 1.1rem;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-dark);
}

button, .btn {
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 1rem;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  transition: all 0.2s ease;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-icon {
  display: inline-flex;
  margin-right: 6px;
}

button:disabled, .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

input, textarea {
  font-family: var(--font-main);
  font-size: 1rem;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: white;
  transition: all 0.2s ease;
  width: 100%;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

/* Container and layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.app-container {
  position: relative;
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  min-height: 85vh;
  max-width: 1200px;
  margin: 2rem auto;
  overflow: hidden;
  transition: all 0.3s ease;
  flex: 1;
}

.app-container.with-sidebar {
  margin-left: 520px;
}

/* Header layout with sidebar toggle and user info */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  background: white;
  border-bottom: 1px solid var(--card-border);
  position: relative;
}

/* Logo with integrated sidebar toggle */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 1rem;
}

.logo h1 {
  font-size: 1.5rem;
  margin: 0;
  background: linear-gradient(45deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* User info styles */
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--medium);
  padding: 8px 16px;
  background: var(--light);
  border-radius: 20px;
}

#userLogin {
  font-weight: 600;
  color: var(--primary);
}

/* Footer with metadata */
.app-footer {
  background: var(--light);
  padding: 0.75rem 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--medium);
  border-top: 1px solid var(--card-border);
}

.metadata {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.version {
  font-weight: 600;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: -500px;
  width: 500px;
  height: 100vh;
  background: white;
  box-shadow: var(--shadow);
  z-index: 100;
  transition: all 0.3s ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar.open {
  left: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}

.sidebar-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.sidebar-version {
  font-size: 0.75rem;
  color: var(--medium);
  margin-left: auto;
  margin-right: 1rem;
}

.sidebar-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--medium);
  cursor: pointer;
  padding: 5px;
}

.sidebar-close:hover {
  color: var(--dark);
}

.sidebar-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--medium);
  margin-bottom: 1rem;
}

.sidebar-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.stat-item {
  background: var(--primary-light);
  padding: 12px;
  border-radius: 12px;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--medium);
}

/* Import/Export controls */
.import-export-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 1.5rem;
}

.export-clear-group {
  display: flex;
  width: 100%;
  gap: 8px;
}

.btn-import, .btn-export {
  padding: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-import {
  background: var(--primary-light);
  color: var(--primary-dark);
  width: 100%;
}

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

.btn-export {
  background: var(--light);
  color: var(--medium);
  flex-grow: 1;
}

.btn-export:hover {
  background: var(--medium);
  color: white;
}

.btn-clear {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 8px;
  background-color: #fff5f5;
  color: var(--danger);
  border: 1px solid #fed7d7;
  transition: all 0.2s ease;
}

.btn-clear:hover {
  background-color: var(--danger);
  color: white;
}

.btn-clear .btn-icon {
  margin: 0;
}

/* Import result styles */
.import-stats {
  background: var(--primary-light);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}

.import-stat {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.import-stat:last-child {
  margin-bottom: 0;
}

.import-stat-label {
  color: var(--medium);
  font-weight: 500;
}

.import-stat-value {
  font-weight: 600;
  color: var(--primary);
}

.primary-btn {
  background: var(--primary);
  color: white;
  padding: 12px 24px;
}

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

.secondary-btn {
  background: var(--light);
  color: var(--medium);
  padding: 12px 24px;
  border: 1px solid var(--card-border);
}

.secondary-btn:hover {
  background: var(--card-border);
  color: var(--dark);
}

.warning-btn {
  background: var(--warning);
  color: white;
  padding: 12px 24px;
}

.warning-btn:hover {
  background: #e67e00;
}

.import-icon {
  color: var(--primary);
}

.warning-icon {
  color: var(--warning);
}

.edit-icon {
  color: var(--medium);
}

/* Sidebar toggle - positioned in logo, always visible */
.sidebar-toggle {
  background: var(--primary);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
  border: none;
  font-size: 1.25rem;
  position: relative;
  top: auto;
  left: auto;
  z-index: auto;
}

.sidebar-toggle:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.sidebar-toggle.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Add card form */
.add-card-form {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--card-border);
  margin-bottom: 1.5rem;
}

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

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--dark);
}

.btn-add {
  background: var(--primary);
  color: white;
  width: 100%;
  padding: 12px;
  margin-top: 10px;
}

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

/* Image upload styles */
.hidden-file-input {
  display: none;
}

.image-upload-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 5px;
}

.image-preview {
  width: 100%;
  height: 120px;
  border: 1px dashed var(--card-border);
  border-radius: 8px;
  background: var(--light);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-placeholder {
  color: var(--medium);
  font-size: 0.9rem;
}

.preview-img {
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
}

.image-upload-controls {
  display: flex;
  gap: 10px;
}

.image-upload-btn {
  background: var(--primary-light);
  color: var(--primary);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 500;
  flex: 1;
  transition: all 0.2s ease;
}

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

.image-remove-btn {
  background: #fff5f5;
  color: var(--danger);
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #fed7d7;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.image-remove-btn:hover:not(:disabled) {
  background: var(--danger);
  color: white;
}

.image-remove-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f8f9fa;
  color: #ced4da;
  border-color: #e9ecef;
}

/* Card list */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 25px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px 4px 30px 4px;
}

/* Card items */
.card-item {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 24px;
  position: relative;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  min-height: fit-content;
  width: 100%;
  height: auto;
  overflow: visible;
}

.card-item:hover {
  border-color: var(--primary-light);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.card-item.current {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

.card-item.learned {
  background-color: #f0fff4;
  border-color: #c6f6d5;
}

.card-item > * {
  flex-shrink: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  width: 100%;
  position: relative;
  flex-shrink: 0;
}

.card-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  font-weight: 600;
  font-size: 0.9rem;
}

.card-status {
  font-size: 1.2rem;
  margin-right: 5px;
}

.card-content {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
  overflow: visible;
  min-height: fit-content;
}

/* Card side content with images */
.card-side-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--card-border);
}

.card-side-content:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.card-side-content.has-image {
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
}

.card-thumbnail-container {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light);
}

.card-thumbnail {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.card-question, .card-answer {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  width: 100%;
  font-size: 1rem;
  line-height: 1.6;
  overflow: visible;
  white-space: normal;
  min-height: fit-content;
}

.card-question {
  font-weight: 500;
  color: var(--dark);
  margin-bottom: 0;
  padding-right: 0;
  flex: 1;
}

.card-answer {
  color: var(--medium);
  font-size: 0.95rem;
  padding-right: 0;
  flex: 1;
}

.card-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: auto;
  width: 100%;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.action-btn {
  background: var(--light);
  border: 1px solid var(--card-border);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.2rem;
  padding: 0;
  color: var(--medium);
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.action-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.edit-btn:hover {
  background: #e6f6ff;
  color: #0074cc;
}

.delete-btn:hover {
  background: #fff5f5;
  color: var(--danger);
}

/* Main content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

/* Study view with better spacing */
.study-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 2rem;
  gap: 0;
}

/* Study header with proper spacing */
.study-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-shrink: 0;
}

.mode-indicator {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Stats display with proper spacing */
.stats-display {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 2rem;
  flex-shrink: 0;
}

.counter {
  font-size: 1rem;
  color: var(--medium);
  padding: 8px 16px;
  background: var(--light);
  border-radius: 20px;
  font-weight: 500;
}

.progress-container {
  flex: 1;
  margin: 0 20px;
}

.progress-bar {
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--medium);
  margin-top: 6px;
}

.progress-percent {
  font-weight: 600;
  color: var(--primary);
}

/* Flashcard section with side navigation on desktop */
.flashcard-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
  flex-shrink: 0;
}

.flashcard-container {
  position: relative;
  perspective: 1000px;
  width: 100%;
  max-width: 600px;
  height: 400px; /* Increased height to accommodate images */
  margin: 0 auto;
}

.flashcard {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.card-side {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  background: white;
  border: 1px solid var(--card-border);
  overflow-y: auto;
}

.card-front {
  background: white;
  color: var(--dark);
}

.card-back {
  background: var(--primary-light);
  color: var(--primary-dark);
  transform: rotateY(180deg);
}

.card-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--medium);
}

/* Card image container */
.card-image-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
  min-height: 0;
  max-height: 200px;
  overflow: hidden;
}

.card-image {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 8px;
}

.card-content-text {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  padding: 1rem;
  overflow-y: auto;
  word-wrap: break-word;
  overflow-wrap: break-word;
  width: 100%;
}

/* Navigation buttons beside flashcard on desktop */
.nav-btn {
  background: var(--light);
  color: var(--dark);
  width: 56px;
  height: 56px;
  border: 1px solid var(--card-border);
  border-radius: 50%;
  font-size: 1.5rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.nav-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: scale(1.1);
}

/* Hide text on desktop navigation buttons */
.nav-btn .btn-text {
  display: none;
}

/* Desktop-only navigation */
.desktop-only-nav {
  display: flex;
}

/* MOBILE: Hide desktop navigation and show mobile controls */
.mobile-controls {
  display: none;
}

.desktop-controls {
  display: block;
}

/* Controls with better spacing */
.controls {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  margin-bottom: 1.5rem;
  padding: 0 1rem;
}

.flip-btn {
  background: var(--primary);
  color: white;
  padding: 14px 28px;
  font-size: 1.1rem;
}

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

/* Learning controls with better spacing */
.learning-controls {
  display: none;
  gap: 1.5rem;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 1.5rem;
  padding: 0 1rem;
}

.correct-btn {
  background: var(--success);
  color: white;
  padding: 14px 28px;
  font-size: 1.1rem;
  order: 2;
}

.correct-btn:hover {
  background: #238b7e;
}

.incorrect-btn {
  background: var(--warning);
  color: white;
  padding: 14px 28px;
  font-size: 1.1rem;
  order: 1;
}

.incorrect-btn:hover {
  background: #e67e00;
}

/* Reset controls */
.reset-controls {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  padding: 0 1rem;
}

.reset-btn {
  background: var(--light);
  color: var(--dark);
  border: 1px solid var(--card-border);
  padding: 12px 20px;
  font-size: 1rem;
}

.reset-btn:hover {
  background: #e9ecef;
}

/* MOBILE: Navigation controls styling */
.navigation-controls-mobile {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1rem;
  padding: 0 1rem;
}

.nav-btn-mobile {
  background: var(--light);
  color: var(--dark);
  padding: 10px 16px;
  border: 1px solid var(--card-border);
  font-size: 0.95rem;
}

.nav-btn-mobile:hover {
  background: #e9ecef;
}

/* Results screen without counters */
.results {
  display: none;
  text-align: center;
  padding: 3rem 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.results-icon {
  font-size: 4rem;
  color: var(--success);
  margin-bottom: 1.5rem;
}

.results-title {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--dark);
}

.results-message {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--medium);
}

.results-submessage {
  font-size: 1.1rem;
  margin-bottom: 3rem;
  color: var(--medium);
}

.results-submessage span {
  font-weight: 600;
  color: var(--primary);
}

.restart-btn {
  background: var(--primary);
  color: white;
  padding: 12px 36px;
  font-size: 1.1rem;
}

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

/* Empty state */
.empty-state {
  display: none;
  text-align: center;
  padding: 3rem 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 4rem;
  color: var(--medium);
  opacity: 0.5;
  margin-bottom: 1.5rem;
}

.empty-title {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--dark);
}

.empty-message {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  color: var(--medium);
}

.empty-state-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 300px;
  margin: 0 auto;
}

@media (min-width: 480px) {
  .empty-state-actions {
    flex-direction: row;
    max-width: 400px;
    justify-content: center;
  }
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalFadeIn 0.3s ease;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
  color: var(--dark);
}

.modal-icon {
  margin-right: 12px;
  font-size: 1.5rem;
}

.delete-icon {
  color: var(--danger);
}

.reset-icon {
  color: var(--warning);
}

.modal-body {
  padding: 1.5rem;
}

.modal-submessage {
  font-size: 1rem;
  color: var(--medium);
  margin-top: 12px;
}

.modal-submessage span {
  font-weight: 600;
  color: var(--danger);
}

.delete-preview {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.preview-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--medium);
  margin-bottom: 4px;
}

.preview-content {
  font-size: 1rem;
  color: var(--dark);
  word-break: break-word;
}

.preview-image {
  margin: 8px 0;
  display: flex;
  justify-content: center;
}

.delete-preview-img {
  max-width: 100%;
  max-height: 150px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid #fed7d7;
}

.modal-message {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  color: var(--dark);
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: #f8f9fa;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.confirm-delete {
  background: var(--danger);
  color: white;
}

.confirm-delete:hover {
  background: #c81e1e;
}

.confirm-reset {
  background: var(--warning);
  color: white;
}

.confirm-reset:hover {
  background: #e67e00;
}

.cancel-btn {
  background: white;
  border: 1px solid var(--card-border);
  color: var(--dark);
}

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

/* Edit card form */
.edit-card-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Animations */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Feedback message */
.feedback {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 15px 20px;
  border-radius: 8px;
  color: white;
  box-shadow: var(--shadow);
  z-index: 3000;
  animation: slideInRight 0.3s ease;
}

.feedback-success {
  background: var(--success);
}

.feedback-error {
  background: var(--danger);
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* PWA Install Prompt */
.install-prompt {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 400px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  animation: slideUpIn 0.3s ease;
}

.install-content {
  display: flex;
  align-items: center;
  padding: 16px;
  position: relative;
}

.install-icon {
  font-size: 2rem;
  margin-right: 16px;
  color: var(--primary);
}

.install-text {
  flex: 1;
}

.install-text h3 {
  margin: 0 0 4px 0;
  font-size: 1rem;
}

.install-text p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--medium);
}

.install-btn {
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  margin-left: 12px;
  font-weight: 600;
}

.install-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--medium);
  cursor: pointer;
  padding: 4px;
}

@keyframes slideUpIn {
  from {
    transform: translate(-50%, 100%);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

/* FIXED: Mobile responsive design */
@media (max-width: 768px) {
  .app-container {
    margin: 1rem;
    min-height: calc(100vh - 2rem);
  }
  
  .app-container.with-sidebar {
    margin-left: 1rem;
  }
  
  .sidebar {
    width: 350px;
    left: -350px;
  }
  
  .header {
    padding: 1rem 1.5rem;
  }
  
  .logo {
    padding-left: 0;
  }
  
  .sidebar-toggle {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  
  .study-view {
    padding: 1rem;
  }
  
  .study-header {
    margin-bottom: 1.5rem;
  }
  
  .stats-display {
    margin-bottom: 1.5rem;
    gap: 15px;
  }
  
  /* MOBILE: Hide desktop nav buttons and show mobile layout */
  .flashcard-section {
    flex-direction: column;
    gap: 0;
  }
  
  .desktop-only-nav {
    display: none;
  }
  
  .flashcard-container {
    height: 350px;
  }
  
  /* MOBILE: Show mobile controls in correct order */
  .mobile-controls {
    display: block;
    margin-top: 1.5rem;
  }
  
  .desktop-controls {
    display: none;
  }
  
  .controls {
    gap: 1rem;
    margin-bottom: 1rem;
  }
  
  .learning-controls {
    gap: 1rem;
    margin-bottom: 1rem;
  }
  
  .navigation-controls-mobile {
    margin-bottom: 1rem;
  }
  
  .reset-controls {
    margin-top: 0;
  }
  
  .flip-btn, .correct-btn, .incorrect-btn {
    padding: 12px 20px;
    font-size: 1rem;
  }
  
  .nav-btn-mobile, .reset-btn {
    padding: 10px 16px;
    font-size: 0.95rem;
  }
  
  .card-content-text {
    font-size: 1.25rem;
  }
  
  .user-info {
    display: none;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 100%;
    left: -100%;
  }
  
  .sidebar-toggle {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }
  
  .header {
    padding: 0.75rem 1rem;
  }
  
  .logo h1 {
    font-size: 1.25rem;
  }
  
  .flashcard-container {
    height: 300px;
  }
  
  .card-content-text {
    font-size: 1.1rem;
  }
  
  .controls, .learning-controls {
    gap: 0.75rem;
    padding: 0 0.5rem;
  }
  
  .navigation-controls-mobile {
    gap: 0.75rem;
    padding: 0 0.5rem;
  }
  
  .flip-btn, .correct-btn, .incorrect-btn {
    padding: 10px 16px;
    font-size: 0.95rem;
  }
  
  .nav-btn-mobile, .reset-btn {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
  
  .results-title {
    font-size: 1.5rem;
  }
  
  .results-message {
    font-size: 1rem;
  }
  
  .modal-content {
    max-width: calc(100% - 20px);
  }
  
  .import-export-controls {
    grid-template-columns: 1fr;
  }
  
  .image-upload-controls {
    flex-direction: column;
  }
}
/* Add these styles to your existing style.css file */

/* Header actions */
.header {
  justify-content: space-between;
}

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

.header-btn {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

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

/* Deck Editor View */
.deck-editor-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 2rem;
  gap: 1.5rem;
}

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

.editor-title {
  margin: 0;
  color: var(--dark);
  font-size: 1.5rem;
}

.editor-actions {
  display: flex;
  gap: 10px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  padding: 10px 16px;
}

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

.btn-success {
  background: var(--success);
  color: white;
  padding: 10px 16px;
}

.btn-success:hover {
  background: #238b7e;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 1rem;
}

.search-container {
  flex: 1;
  max-width: 400px;
}

.search-input {
  padding: 10px 16px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  font-size: 0.95rem;
}

.sort-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: white;
  font-size: 0.95rem;
}

.card-grid-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.editor-card {
  background: white;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  height: 220px;
}

.editor-card:hover {
  box-shadow: 0 5px 15px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.editor-card.learned {
  background-color: #f0fff4;
  border-color: #c6f6d5;
}

.card-status-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  font-size: 0.8rem;
  border-radius: 12px;
  font-weight: 600;
}

.status-learning {
  background: #fff7e6;
  color: #d48806;
}

.status-learned {
  background: #f0fff4;
  color: #52c41a;
}

.editor-card-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-card-front {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--dark);
}

.editor-card-back {
  font-size: 0.95rem;
  color: var(--medium);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.editor-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 1rem;
}

.card-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light);
  border: 1px solid var(--card-border);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.card-action-btn:hover {
  transform: translateY(-2px);
}

.edit-btn-small:hover {
  background: #e6f6ff;
  color: #0074cc;
}

.delete-btn-small:hover {
  background: #fff5f5;
  color: var(--danger);
}

.move-btn-small:hover {
  background: #f0f0f0;
  color: var(--dark);
}

.editor-footer {
  display: flex;
  justify-content: center;
  padding: 1rem 0;
}

.btn-outline {
  background: white;
  color: var(--dark);
  border: 1px solid var(--card-border);
  padding: 10px 20px;
}

.btn-outline:hover {
  background: #f1f3f5;
}

/* Card Editor Modal */
.card-editor-modal {
  max-width: 600px;
  width: 95%;
}

.edit-card-form {
  width: 100%;
}

.card-editor-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 1rem;
  resize: vertical;
}

.label-with-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-label {
  font-size: 0.9rem;
  color: var(--medium);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--success);
}

input:focus + .toggle-slider {
  box-shadow: 0 0 1px var(--success);
}

input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

.confirm-edit {
  background: var(--success);
  color: white;
}

.confirm-edit:hover {
  background: #238b7e;
}

.edit-icon {
  color: #0074cc;
}

/* Template Modal */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 1rem;
}

.template-card {
  background: white;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.template-card-inner {
  padding: 1rem;
}

.template-card h4 {
  margin: 0 0 8px 0;
  font-size: 1rem;
}

.template-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--medium);
}

.template-icon {
  color: var(--primary);
}

/* Responsive styles */
@media (max-width: 768px) {
  .editor-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .editor-actions {
    width: 100%;
  }
  
  .editor-toolbar {
    flex-direction: column;
    gap: 1rem;
  }
  
  .search-container {
    max-width: 100%;
  }
  
  .card-grid {
    grid-template-columns: 1fr;
  }
  
  .card-editor-modal {
    width: 90%;
  }
}
/* Add these styles to your existing style.css file */

/* Edit Deck Button in Study View */
.edit-deck-btn {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.edit-deck-btn:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

/* Updated Study Header to accommodate Edit Deck Button */
.study-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-shrink: 0;
}

/* Deck Editor View */
.deck-editor-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 2rem;
  gap: 1.5rem;
}

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

.editor-title {
  margin: 0;
  color: var(--dark);
  font-size: 1.5rem;
}

.editor-actions {
  display: flex;
  gap: 10px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  padding: 10px 16px;
}

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

.btn-success {
  background: var(--success);
  color: white;
  padding: 10px 16px;
}

.btn-success:hover {
  background: #238b7e;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 1rem;
}

.search-container {
  flex: 1;
  max-width: 400px;
}

.search-input {
  padding: 10px 16px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  font-size: 0.95rem;
}

.sort-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: white;
  font-size: 0.95rem;
}

.card-grid-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.editor-card {
  background: white;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  height: 220px;
}

.editor-card:hover {
  box-shadow: 0 5px 15px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.editor-card.learned {
  background-color: #f0fff4;
  border-color: #c6f6d5;
}

.card-status-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  font-size: 0.8rem;
  border-radius: 12px;
  font-weight: 600;
}

.status-learning {
  background: #fff7e6;
  color: #d48806;
}

.status-learned {
  background: #f0fff4;
  color: #52c41a;
}

.editor-card-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-card-front {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--dark);
}

.editor-card-back {
  font-size: 0.95rem;
  color: var(--medium);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.editor-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 1rem;
}

.card-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light);
  border: 1px solid var(--card-border);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.card-action-btn:hover {
  transform: translateY(-2px);
}

.edit-btn-small:hover {
  background: #e6f6ff;
  color: #0074cc;
}

.delete-btn-small:hover {
  background: #fff5f5;
  color: var(--danger);
}

.move-btn-small:hover {
  background: #f0f0f0;
  color: var(--dark);
}

.editor-footer {
  display: flex;
  justify-content: center;
  padding: 1rem 0;
}

.btn-outline {
  background: white;
  color: var(--dark);
  border: 1px solid var(--card-border);
  padding: 10px 20px;
}

.btn-outline:hover {
  background: #f1f3f5;
}

/* Card Editor Modal */
.card-editor-modal {
  max-width: 600px;
  width: 95%;
}

.edit-card-form {
  width: 100%;
}

.card-editor-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 1rem;
  resize: vertical;
}

.label-with-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-label {
  font-size: 0.9rem;
  color: var(--medium);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--success);
}

input:focus + .toggle-slider {
  box-shadow: 0 0 1px var(--success);
}

input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

.confirm-edit {
  background: var(--success);
  color: white;
}

.confirm-edit:hover {
  background: #238b7e;
}

.edit-icon {
  color: #0074cc;
}

/* Template Modal */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 1rem;
}

.template-card {
  background: white;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.template-card-inner {
  padding: 1rem;
}

.template-card h4 {
  margin: 0 0 8px 0;
  font-size: 1rem;
}

.template-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--medium);
}

.template-icon {
  color: var(--primary);
}

.empty-grid-message {
  text-align: center;
  padding: 2rem;
  color: var(--medium);
  grid-column: 1 / -1;
}

/* Responsive styles */
@media (max-width: 768px) {
  .study-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .edit-deck-btn {
    align-self: flex-end;
  }
  
  .editor-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .editor-actions {
    width: 100%;
  }
  
  .editor-toolbar {
    flex-direction: column;
    gap: 1rem;
  }
  
  .search-container {
    max-width: 100%;
  }
  
  .card-grid {
    grid-template-columns: 1fr;
  }
  
  .card-editor-modal {
    width: 90%;
  }
}

@media (max-width: 480px) {
  .editor-card {
    height: auto;
    min-height: 180px;
  }
}