/* === AUTHENTICATION STYLES === */
#authSection {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #444;
}

#userInfo {
  display: none;
  text-align: center;
}

#userPhoto {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-bottom: 10px;
}

#userName {
  margin: 0 0 10px 0;
  font-size: 14px;
}

#signOutBtn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
}

#googleSignInBtn {
  background: #4285f4;
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

#googleSignInBtn:hover {
  background: #3367d6;
}

#signOutBtn:hover {
  background: #c82333;
}

#saveVoiceBtn {
  display: none;
  background: #28a745;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 8px;
}

#saveVoiceBtn:hover {
  background: #218838;
}

/* === SEARCH AND FILTER STYLES === */
#searchFilterDiv {
  margin-bottom: 1.5rem;
}

#searchDiv {
  position: relative;
  margin-bottom: 1rem;
}

#searchInput {
  width: 100%;
  padding: 12px 40px 12px 12px;
  border: 2px solid #444;
  border-radius: 8px;
  background: #333;
  color: #eee;
  font-size: 16px;
  transition: all 0.3s ease;
}

#searchInput:focus {
  outline: none;
  border-color: #d35400;
  box-shadow: 0 0 0 3px rgba(211, 84, 0, 0.1);
  transform: scale(1.02);
}

#clearSearchBtn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: #666;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 12px;
  display: none;
}

#clearSearchBtn:hover {
  background: #888;
}

/* === EDIT MODAL STYLES === */
.edit-entry-modal {
  background: #222;
  padding: 2rem;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.edit-entry-modal h3 {
  color: #d35400;
  margin: 0 0 1.5rem 0;
  text-align: center;
}

.edit-entry-modal label {
  display: block;
  margin-bottom: 0.5rem;
  color: #eee;
  font-weight: 500;
}

.edit-entry-modal input,
.edit-entry-modal select,
.edit-entry-modal textarea {
  width: 100%;
  padding: 10px;
  margin-bottom: 1rem;
  border: 2px solid #444;
  border-radius: 6px;
  background: #333;
  color: #eee;
  font-size: 14px;
}

.edit-entry-modal input:focus,
.edit-entry-modal select:focus,
.edit-entry-modal textarea:focus {
  outline: none;
  border-color: #d35400;
}

#editAudioPlayer {
  margin-bottom: 1rem;
}

#editAudioPlayer audio {
  width: 100%;
}

#replaceVoiceBtn {
  background: #ffc107;
  color: #000;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 1rem;
}

#replaceVoiceBtn:hover {
  background: #e0a800;
}

/* === ENTRY CARD STYLES === */
.entry {
  background: #333;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  border-left: 4px solid #d35400;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  position: relative;
}

.entry:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.entry.expanded {
  border-left-color: #ffc107;
}

.entry-content {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.entry-content.collapsed {
  max-height: 120px; /* Show only 2-3 lines */
}

.entry-content.expanded {
  max-height: none;
}

.entry-text-preview {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  margin-top: 0.5rem;
}

.entry-text-full {
  margin-top: 0.5rem;
  line-height: 1.4;
}

.entry-expand-indicator {
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: #888;
  font-size: 12px;
  transition: transform 0.2s ease;
}

.entry.expanded .entry-expand-indicator {
  transform: rotate(180deg);
}

.entry-title {
  font-size: 1.1rem;
  font-weight: bold;
  color: #d35400;
  margin-bottom: 0.5rem;
}

.entry-mood {
  font-weight: 600;
  margin: 0.6rem 0;
  text-transform: uppercase;
  color: #ffc107;
}

.entry-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

.entry-actions button {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.edit-btn {
  background: #007bff;
  color: white;
}

.edit-btn:hover {
  background: #0056b3;
}

.delete-btn {
  background: #dc3545;
  color: white;
}

.delete-btn:hover {
  background: #c82333;
}

/* === MOBILE-FIRST BASE STYLES === */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #111;
  color: #eee;
  margin: 0;
  padding: 1rem;
  transition: background-color 0.3s, color 0.3s;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 100%;
  margin: 0 auto;
  padding: 1rem;
  background: #222;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: calc(100vh - 2rem);
}

.app > * {
  margin-bottom: 1.5rem;
}

h1, h2 {
  color: #d35400;
  font-size: 1.8rem;
  margin: 0 0 1rem 0;
  word-break: break-word;
  text-align: center;
}

h2 {
  font-size: 1.4rem;
}

/* === FORM STYLES === */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

form > * {
  margin-bottom: 0.8rem;
}

label {
  font-weight: 600;
  color: #d35400;
  margin-bottom: 0.5rem;
  display: block;
}

select, textarea, button, input {
  padding: 0.875rem;
  border-radius: 8px;
  border: 2px solid transparent;
  font-size: 1rem;
  width: 100%;
  transition: all 0.3s ease;
  font-family: inherit;
}

select:focus, textarea:focus, input:focus {
  outline: none;
  border-color: #d35400;
  box-shadow: 0 0 0 3px rgba(211, 84, 0, 0.1);
}

textarea {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
}

button {
  background: #d35400;
  color: white;
  cursor: pointer;
  border: none;
  font-weight: 600;
  transition: all 0.3s ease;
  padding: 1rem;
  font-size: 1rem;
}

button:hover {
  background: #bc4800;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  background: #666;
  cursor: not-allowed;
  transform: none;
}

/* === ENTRIES === */
#entries {
  margin-top: 1.5rem;
}

.entry {
  background: #333;
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-left: 4px solid #d35400;
}

.entry small {
  color: #aaa;
  font-size: 0.85rem;
  display: block;
  margin-bottom: 0.5rem;
}

/* === FILTER === */
#filterDiv {
  margin: 1.5rem 0;
}

#filterDiv select {
  background: #333;
  color: #fff;
  border: 2px solid #555;
}

/* === SIDEBAR, HAMBURGER, OVERLAY === */
#sidebar,
#hamburger,
#sidebarOverlay {
  display: none;
}

body.unlocked #sidebar {
  display: block;
}

body.unlocked #hamburger {
  display: flex;
}

body.unlocked #sidebarOverlay {
  display: none;
}

body.unlocked #sidebar.open ~ #sidebarOverlay {
  display: block;
}

#sidebar.open ~ #hamburger {
  display: none !important;
}

#sidebar.open ~ #sidebarOverlay {
  display: block;
}

/* === SIDEBAR STYLES === */
#sidebar {
  position: fixed;
  top: 0;
  left: -100vw;
  width: 280px;
  height: 100vh;
  padding: 2rem 1.5rem;
  z-index: 2000;
  transition: left 0.3s ease;
  background: #111;
  color: #d35400;
  overflow-y: auto;
}

#sidebar.open {
  left: 0 !important;
  box-shadow: 4px 0 20px rgba(211, 84, 0, 0.3);
}

#sidebar button {
  margin-bottom: 1rem;
  width: 100%;
  text-align: left;
  padding: 1rem;
  background: #d35400;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s ease;
}

#sidebar button:hover {
  background: #bc4800;
  transform: translateX(4px);
}

#sidebar select {
  margin-top: 1rem;
  width: 100%;
  background: #333;
  color: #fff;
  border: 2px solid #555;
  padding: 0.75rem;
  border-radius: 6px;
}

/* === HAMBURGER ICON === */
#hamburger {
  position: fixed;
  top: 1rem;
  left: 1rem;
  width: 50px;
  height: 50px;
  z-index: 2100;
  cursor: pointer;
  display: none; /* Hidden by default, only shown when unlocked */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.8);
  border: 2px solid #d35400;
  border-radius: 8px;
  padding: 10px;
  transition: all 0.3s ease;
}

#hamburger:hover {
  background: rgba(0,0,0,0.9);
  border-color: #bc4800;
}

#hamburger div {
  width: 24px;
  height: 3px;
  background: #d35400;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* === SIDEBAR OVERLAY === */
#sidebarOverlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1500;
  display: none;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* === MODAL STYLES === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 1rem;
}

.full-entry-modal {
  width: 100%;
  max-width: 400px;
  min-height: 200px;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(211, 84, 0, 0.3);
  padding: 2rem;
  background: #222;
  color: #fff;
  transition: all 0.3s ease;
}

.full-entry-modal button {
  margin: 0.5rem 0.25rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

.modal-close-btn {
  background: #e74c3c !important;
  color: #fff !important;
}

.modal-close-btn:hover {
  background: #c0392b !important;
}

/* === PASSCODE SCREENS === */
#setPasscodeScreen,
#lockScreen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1.5rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

#setPasscodeScreen input,
#lockScreen input {
  margin-bottom: 0.5rem;
}

#setPasscodeScreen button,
#lockScreen button {
  margin-bottom: 0.5rem;
}

#setPasscodeError,
#passcodeError {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  color: #e74c3c;
  font-size: 0.9rem;
  text-align: center;
}

/* === VOICE CONTROLS === */
.voice-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem 0;
  padding: 1rem;
  background: #333;
  border-radius: 8px;
  border: 2px solid #555;
}

.voice-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: #d35400;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
  font-weight: 600;
}

.voice-controls button:hover {
  background: #bc4800;
  transform: translateY(-2px);
}

.voice-controls button.recording {
  background: #e74c3c;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.02); }
  100% { opacity: 1; transform: scale(1); }
}

.voice-hint {
  color: #aaa;
  font-size: 0.85rem;
  text-align: center;
  margin-top: 0.5rem;
}

.record-status {
  font-size: 1rem;
  font-weight: 600;
}

/* === AUDIO ELEMENTS === */
.audio-wrap {
  margin: 1rem 0;
  padding: 1rem;
  background: #333;
  border-radius: 8px;
  border: 2px solid #555;
}

.audio-wrap audio {
  width: 100%;
  margin-bottom: 0.75rem;
  border-radius: 4px;
}

.audio-delete {
  background: #e74c3c !important;
  color: white !important;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.3s ease;
}

.audio-delete:hover {
  background: #c0392b !important;
  transform: translateY(-1px);
}

/* === LIGHT MODE === */
body.light-mode {
  background-color: #f7f7f7;
  color: #222;
}

body.light-mode .app {
  background: #fff;
  color: #222;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

body.light-mode input,
body.light-mode select,
body.light-mode textarea {
  background-color: #fff;
  color: #222;
  border: 2px solid #ddd;
}

body.light-mode input:focus,
body.light-mode select:focus,
body.light-mode textarea:focus {
  border-color: #d35400;
  box-shadow: 0 0 0 3px rgba(211, 84, 0, 0.1);
}

body.light-mode #filterDiv select {
  background: #fff;
  color: #222;
  border: 2px solid #ddd;
}

body.light-mode ::placeholder,
body.light-mode input::placeholder,
body.light-mode textarea::placeholder {
  color: #666;
  opacity: 0.8;
}

body.light-mode button {
  background: #d35400;
  color: #fff;
}

body.light-mode button:hover {
  background: #bc4800;
}

body.light-mode .entry {
  background: #f8f9fa;
  color: #222;
  border-left-color: #d35400;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body.light-mode .entry small {
  color: #666;
}

body.light-mode #sidebar {
  background: #f7f7f7;
  color: #d35400;
}

body.light-mode #sidebar.open {
  box-shadow: 4px 0 20px rgba(211, 84, 0, 0.2);
}

body.light-mode #hamburger {
  background: rgba(255,255,255,0.9);
}

body.light-mode #hamburger:hover {
  background: rgba(255,255,255,1);
}

body.light-mode .full-entry-modal {
  background: #fff;
  color: #222;
  box-shadow: 0 10px 30px rgba(211, 84, 0, 0.2);
}

body.light-mode .voice-controls {
  background: #f8f9fa;
  border: 2px solid #ddd;
}

body.light-mode .voice-hint {
  color: #666;
}

body.light-mode .audio-wrap {
  background: #f8f9fa;
  border: 2px solid #ddd;
}

/* === ADDITIONAL UTILITY CLASSES === */
.language-select {
  margin-top: 1rem;
  width: 100%;
}

.error-message {
  display: none;
  color: #e74c3c;
  font-size: 0.9rem;
  text-align: center;
  margin-top: 0.5rem;
}

.modal-hidden {
  display: none;
}

.modal-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.modal-buttons button {
  flex: 1;
  min-width: 120px;
}

/* === DARK MODE OVERRIDES === */
body.dark-mode {
  background-color: #111;
  color: #fff;
}

body.dark-mode .app {
  background: #222;
  color: #fff;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background-color: #333;
  color: #fff;
  border: 2px solid #555;
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
  border-color: crimson;
  box-shadow: 0 0 0 3px rgba(211, 84, 0, 0.2);
}

body.dark-mode #filterDiv select {
  background: #333;
  color: #fff;
  border: 2px solid #555;
}

body.dark-mode ::placeholder,
body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #ccc;
  opacity: 0.8;
}

body.dark-mode h1,
body.dark-mode h2 {
  color: crimson;
}

body.dark-mode #sidebar {
  color: crimson;
}

body.dark-mode #hamburger div {
  background: crimson;
}

body.dark-mode .full-entry-modal {
  box-shadow: 0 10px 30px rgba(211, 84, 0, 0.3);
}

/* === TABLET STYLES (768px and up) === */
@media (min-width: 768px) {
  body {
    padding: 2rem;
  }
  
  .app {
    max-width: 600px;
    padding: 2rem;
    min-height: calc(100vh - 4rem);
  }
  
  h1, h2 {
    font-size: 2.2rem;
    text-align: left;
  }
  
  h2 {
    font-size: 1.6rem;
  }
  
  form {
    gap: 1.25rem;
  }
  
  select, textarea, button, input {
    padding: 1rem;
    font-size: 1.1rem;
  }
  
  textarea {
    min-height: 140px;
  }
  
  .entry {
    padding: 2rem;
  }
  
  #sidebar {
    width: 300px;
  }
  
  .full-entry-modal {
    max-width: 500px;
  }
}

/* === DESKTOP STYLES (1024px and up) === */
@media (min-width: 1024px) {
  .app {
    max-width: 800px;
    padding: 2.5rem;
  }
  
  h1, h2 {
    font-size: 2.5rem;
  }
  
  h2 {
    font-size: 1.8rem;
  }
  
  form {
    gap: 1.5rem;
  }
  
  select, textarea, button, input {
    padding: 1.25rem;
    font-size: 1.1rem;
  }
  
  textarea {
    min-height: 160px;
  }
  
  .entry {
    padding: 2.5rem;
  }
  
  #sidebar {
    width: 320px;
  }
  
  .full-entry-modal {
    max-width: 600px;
  }
}

/* === LARGE DESKTOP STYLES (1440px and up) === */
@media (min-width: 1440px) {
  .app {
    max-width: 900px;
  }
  
  h1, h2 {
    font-size: 3rem;
  }
  
  h2 {
    font-size: 2rem;
  }
}