/* Import Space Grotesk Font */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap');

/* CSS Variables - Reduced White Color Scheme */
:root {
  --black: #000000;
  --dark-grey: #1a1a1a;
  --medium-grey: #333333;
  --light-grey: #666666;
  --very-light-grey: #999999;
  --off-white: #e6e6e6;
  --pure-white: #ffffff;
  --red: #ff0000;
  --dark-red: #cc0000;
  --green: #00cc00;
  --yellow: #ffa500;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background-color: var(--black);
  color: var(--off-white);
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  overflow: hidden;
  font-weight: 400;
  position: fixed;
  width: 100%;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  text-align: center;
}

.app-logo {
  font-size: 36px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 20px;
  letter-spacing: 3px;
  border: 3px solid var(--red);
  padding: 12px 24px;
  background: var(--off-white);
  color: var(--black);
}

.loading-bar {
  width: 160px;
  height: 6px;
  background: var(--dark-grey);
  border: 2px solid var(--off-white);
  position: relative;
  overflow: hidden;
}

.loading-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--red);
  animation: loading-slide 2s infinite;
}

@keyframes loading-slide {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* FIXED: Main App - Proper Mobile Layout */
.app-container {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
  position: relative;
  overflow: hidden;
}

/* FIXED: Header - Sticky and Compact */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--black);
  padding: 8px 12px;
  border-bottom: 3px solid var(--off-white);
  flex-shrink: 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.app-branding {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 1;
  min-width: 0;
}

.app-title {
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 700;
  color: var(--red);
  letter-spacing: 1px;
  line-height: 1;
}

.app-subtitle {
  font-size: clamp(7px, 1.5vw, 9px);
  font-weight: 600;
  color: var(--very-light-grey);
  letter-spacing: 1px;
}

.nav-container {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.nav-button {
  background: var(--off-white);
  color: var(--black);
  border: 2px solid var(--black);
  padding: 6px 12px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(9px, 2vw, 11px);
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.1s ease;
  text-transform: uppercase;
  box-shadow: 2px 2px 0px var(--black);
  min-height: 32px;
  white-space: nowrap;
}

.nav-button:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--black);
}

.nav-button.active {
  background: var(--red);
  color: var(--off-white);
  border-color: var(--black);
  box-shadow: 2px 2px 0px var(--black);
}

/* FIXED: Main Content - Proper Scrolling Setup */
.main-content {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  height: 100%;
  flex-direction: column;
}

.view.active {
  display: flex;
}

/* FIXED: Record View - Mobile Viewport Layout */
.record-layout {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* FIXED: Status Panel - Compact and Sticky */
.status-panel {
  background: var(--yellow);
  color: var(--black);
  border-bottom: 2px solid var(--black);
  padding: 8px 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.status-label {
  font-weight: 700;
  font-size: clamp(10px, 2.5vw, 12px);
  letter-spacing: 1px;
  flex: 1;
  min-width: 0;
}

.status-label.recording {
  color: var(--red);
}

.timer-display {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: clamp(12px, 3vw, 14px);
  background: var(--black);
  color: var(--off-white);
  padding: 4px 8px;
  border: 2px solid var(--black);
  min-width: 50px;
  text-align: center;
  flex-shrink: 0;
}

.timer-display.recording {
  background: var(--red);
  color: var(--off-white);
  animation: timer-blink 1s infinite;
}

@keyframes timer-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.7; }
}

/* FIXED: Scrollable Content Area */
.scrollable-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.transcript-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-title {
  font-size: clamp(12px, 3vw, 14px);
  font-weight: 700;
  color: var(--off-white);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.transcript-area {
  background: var(--dark-grey);
  color: var(--off-white);
  border: 2px solid var(--off-white);
  padding: 12px;
  font-size: clamp(11px, 2.5vw, 13px);
  line-height: 1.4;
  white-space: pre-wrap;
  box-shadow: 3px 3px 0px var(--off-white);
  min-height: 120px;
  max-height: 200px;
  overflow-y: auto;
}

.transcript-area.empty {
  color: var(--light-grey);
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 120px;
}

.transcript-area::-webkit-scrollbar {
  width: 6px;
}

.transcript-area::-webkit-scrollbar-track {
  background: var(--black);
}

.transcript-area::-webkit-scrollbar-thumb {
  background: var(--off-white);
  border: 1px solid var(--black);
}

/* FIXED: Control Panel - Side by Side Buttons */
.control-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  flex-shrink: 0;
}

.record-btn, .stop-btn {
  background: var(--red);
  color: var(--off-white);
  border: 3px solid var(--black);
  padding: 12px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.1s ease;
  box-shadow: 4px 4px 0px var(--black);
  min-width: clamp(70px, 18vw, 90px);
  min-height: clamp(60px, 15vw, 70px);
  flex: 1;
  max-width: 120px;
}

.record-btn:hover, .stop-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px var(--black);
}

.record-btn.recording {
  background: var(--off-white);
  color: var(--black);
  animation: record-shake 0.5s infinite;
}

.record-btn.paused {
  background: var(--yellow);
  color: var(--black);
}

.record-btn.processing {
  background: var(--green);
  color: var(--black);
  animation: process-spin 1s infinite linear;
}

@keyframes record-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(1px, 0); }
  75% { transform: translate(-1px, 0); }
}

@keyframes process-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.stop-btn {
  background: var(--off-white);
  color: var(--black);
}

.btn-icon svg {
  width: clamp(14px, 4vw, 18px);
  height: clamp(14px, 4vw, 18px);
}

.btn-label {
  font-size: clamp(7px, 2vw, 9px);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Scrollbar for main content */
.scrollable-content::-webkit-scrollbar {
  width: 6px;
}

.scrollable-content::-webkit-scrollbar-track {
  background: var(--black);
}

.scrollable-content::-webkit-scrollbar-thumb {
  background: var(--off-white);
  border-radius: 3px;
}

.scrollable-content::-webkit-scrollbar-thumb:hover {
  background: var(--very-light-grey);
}

/* Notes View - Reduced Grid */
.notes-layout {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.filter-panel {
  flex-shrink: 0;
  padding: 12px;
  background: var(--black);
  border-bottom: 2px solid var(--off-white);
}

.filter-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px;
}

.filter-scroll::-webkit-scrollbar {
  height: 4px;
}

.filter-scroll::-webkit-scrollbar-track {
  background: var(--black);
}

.filter-scroll::-webkit-scrollbar-thumb {
  background: var(--off-white);
  border-radius: 2px;
}

.filter-btn {
  background: var(--off-white);
  color: var(--black);
  border: 2px solid var(--black);
  padding: clamp(4px, 1.5vw, 6px) clamp(8px, 2.5vw, 12px);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(8px, 2vw, 10px);
  letter-spacing: 1px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.1s ease;
  box-shadow: 2px 2px 0px var(--black);
  min-height: 28px;
}

.filter-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--black);
}

.filter-btn.active {
  background: var(--red);
  color: var(--off-white);
}

.notes-grid {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vw, 12px);
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

.notes-grid::-webkit-scrollbar {
  width: 6px;
}

.notes-grid::-webkit-scrollbar-track {
  background: var(--black);
}

.notes-grid::-webkit-scrollbar-thumb {
  background: var(--off-white);
  border: 1px solid var(--black);
  border-radius: 3px;
}

.note-card {
  background: var(--off-white);
  color: var(--black);
  border: 3px solid var(--black);
  padding: clamp(12px, 3vw, 16px);
  cursor: pointer;
  transition: all 0.1s ease;
  box-shadow: 4px 4px 0px var(--black);
  position: relative;
  overflow: hidden;
  min-height: 60px;
}

.note-card:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px var(--black);
}

/* Updated Swipe Indicators */
.note-card.swiping-right {
  background: var(--green) !important;
  color: var(--black) !important;
  transform: translateX(clamp(30px, 8vw, 50px));
  box-shadow: 4px 4px 0px var(--black);
}

.note-card.swiping-left {
  background: var(--yellow) !important;
  color: var(--black) !important;
  transform: translateX(clamp(-30px, -8vw, -50px));
  box-shadow: 4px 4px 0px var(--black);
}

.note-card.completed {
  background: var(--light-grey);
  color: var(--off-white);
  opacity: 0.8;
}

.note-card.completed .note-title {
  text-decoration: line-through;
}

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.note-title {
  font-size: clamp(14px, 3vw, 16px);
  font-weight: 700;
  color: inherit;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
  flex: 1;
  min-width: 0;
}

.note-date {
  font-size: clamp(8px, 2vw, 10px);
  color: var(--medium-grey);
  font-weight: 600;
}

.note-category-badge {
  background: var(--black);
  color: var(--off-white);
  padding: 2px 6px;
  font-size: clamp(7px, 1.8vw, 8px);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid var(--black);
  flex-shrink: 0;
}

.note-preview {
  color: var(--medium-grey);
  font-size: clamp(10px, 2.5vw, 12px);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 400;
}

.empty-state {
  text-align: center;
  color: var(--light-grey);
  font-style: italic;
  padding: clamp(30px, 8vw, 50px) 16px;
  font-size: clamp(14px, 3vw, 16px);
  letter-spacing: 1px;
}

/* Modals - Reduced Size */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: clamp(12px, 3vw, 16px);
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--off-white);
  color: var(--black);
  border: 4px solid var(--black);
  width: 100%;
  max-width: clamp(280px, 85vw, 450px);
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 8px 8px 0px var(--black);
}

.modal-box.modal-large {
  max-width: clamp(300px, 90vw, 600px);
}

.modal-box.modal-small {
  max-width: clamp(250px, 80vw, 350px);
}

/* Simplified Note Detail Modal Header */
.modal-header {
  padding: clamp(12px, 3vw, 16px);
  border-bottom: 3px solid var(--black);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--red);
  color: var(--off-white);
  flex-wrap: wrap;
  gap: 8px;
}

.modal-title {
  font-size: clamp(14px, 3.5vw, 16px);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  flex: 1;
  min-width: 0;
}

/* Simplified Action Buttons */
.note-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.action-btn {
  background: var(--off-white);
  color: var(--black);
  border: 2px solid var(--black);
  padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px);
  cursor: pointer;
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.1s ease;
  letter-spacing: 1px;
  text-transform: uppercase;
  min-height: 32px;
}

.action-btn:hover {
  background: var(--black);
  color: var(--off-white);
}

.action-btn svg {
  width: clamp(12px, 3vw, 14px);
  height: clamp(12px, 3vw, 14px);
}

.modal-body {
  padding: clamp(12px, 3vw, 16px);
  overflow-y: auto;
  max-height: 50vh;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: var(--off-white);
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--black);
}

.input-section {
  margin-bottom: clamp(12px, 3vw, 16px);
}

.input-label {
  display: block;
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 700;
  color: var(--black);
  margin-bottom: 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.input-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.text-input, .select-input {
  width: 100%;
  background: var(--off-white);
  border: 2px solid var(--black);
  padding: clamp(8px, 2vw, 10px);
  color: var(--black);
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 600;
  outline: none;
  transition: all 0.1s ease;
  box-shadow: 2px 2px 0px var(--black);
  min-height: 36px;
}

.text-area {
  width: 100%;
  background: var(--off-white);
  border: 2px solid var(--black);
  padding: clamp(8px, 2vw, 10px);
  color: var(--black);
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 400;
  outline: none;
  transition: all 0.1s ease;
  box-shadow: 2px 2px 0px var(--black);
  resize: vertical;
  min-height: 100px;
}

.text-input:focus, .select-input:focus, .text-area:focus {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--black);
}

.text-input::placeholder {
  color: var(--light-grey);
  font-style: italic;
}

.regen-btn {
  width: clamp(36px, 8vw, 40px);
  height: clamp(36px, 8vw, 40px);
  background: var(--black);
  color: var(--off-white);
  border: 2px solid var(--black);
  cursor: pointer;
  font-size: clamp(14px, 3.5vw, 16px);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
  box-shadow: 2px 2px 0px var(--black);
  flex-shrink: 0;
}

.regen-btn:hover {
  background: var(--red);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--black);
}

.summary-box {
  background: var(--dark-grey);
  color: var(--off-white);
  border: 2px solid var(--black);
  padding: clamp(10px, 2.5vw, 12px);
  font-size: clamp(10px, 2.5vw, 12px);
  line-height: 1.5;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-style: italic;
  box-shadow: 2px 2px 0px var(--black);
}

.summary-box.loaded {
  justify-content: flex-start;
  align-items: flex-start;
  text-align: left;
  font-style: normal;
}

.modal-footer {
  padding: clamp(12px, 3vw, 16px);
  border-top: 3px solid var(--black);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--off-white);
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary, .btn-danger {
  padding: clamp(8px, 2vw, 10px) clamp(12px, 3vw, 16px);
  border: 2px solid var(--black);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(10px, 2.5vw, 12px);
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.1s ease;
  box-shadow: 2px 2px 0px var(--black);
  text-transform: uppercase;
  min-height: 36px;
  min-width: 60px;
}

.btn-primary {
  background: var(--red);
  color: var(--off-white);
}

.btn-primary:hover:not(:disabled) {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--black);
}

.btn-primary:disabled {
  background: var(--light-grey);
  color: var(--off-white);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--off-white);
  color: var(--black);
}

.btn-secondary:hover {
  background: var(--medium-grey);
  color: var(--off-white);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--black);
}

.btn-danger {
  background: var(--off-white);
  color: var(--black);
}

.btn-danger:hover {
  background: var(--red);
  color: var(--off-white);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--black);
}

/* Edit Controls - Reduced */
.edit-controls {
  border: 2px solid var(--black);
  padding: clamp(12px, 3vw, 16px);
  margin-bottom: 16px;
  background: var(--dark-grey);
  color: var(--off-white);
}

.edit-controls .input-label {
  color: var(--off-white);
}

.edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Note Detail Content - Reduced */
.note-metadata {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--black);
  flex-wrap: wrap;
}

.meta-date {
  font-size: clamp(10px, 2.5vw, 12px);
  color: var(--medium-grey);
  font-weight: 600;
}

.meta-category {
  background: var(--black);
  color: var(--off-white);
  padding: 2px 6px;
  font-size: clamp(8px, 2vw, 10px);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.content-block {
  margin-bottom: clamp(12px, 3vw, 16px);
}

.content-heading {
  font-size: clamp(12px, 3vw, 14px);
  font-weight: 700;
  color: var(--black);
  margin-bottom: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.content-box {
  background: var(--dark-grey);
  color: var(--off-white);
  border: 2px solid var(--black);
  padding: clamp(10px, 2.5vw, 12px);
  font-size: clamp(10px, 2.5vw, 12px);
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
  box-shadow: 2px 2px 0px var(--black);
}

.content-box::-webkit-scrollbar {
  width: 6px;
}

.content-box::-webkit-scrollbar-track {
  background: var(--black);
}

.content-box::-webkit-scrollbar-thumb {
  background: var(--off-white);
}

.warning-text {
  font-size: clamp(12px, 3vw, 14px);
  line-height: 1.4;
  color: var(--black);
  text-align: center;
  font-weight: 600;
}

/* Focus States - Enhanced for accessibility */
.nav-button:focus,
.record-btn:focus,
.stop-btn:focus,
.filter-btn:focus,
.btn-primary:focus,
.btn-secondary:focus,
.btn-danger:focus,
.action-btn:focus,
.regen-btn:focus {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}

/* Enhanced Mobile Support */
@media (max-width: 480px) {
  body {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  
  .app-header {
    padding: 6px 8px;
  }
  
  .nav-button {
    padding: 4px 8px;
    min-height: 28px;
    font-size: 9px;
  }
  
  .status-panel {
    padding: 6px 8px;
  }
  
  .scrollable-content {
    padding: 8px;
  }
  
  .control-panel {
    padding: 12px 0 20px;
  }
  
  .record-btn, .stop-btn {
    min-width: 80px;
    min-height: 60px;
    padding: 10px;
  }
}

@media (max-height: 600px) {
  .transcript-area {
    min-height: 80px;
    max-height: 120px;
  }
  
  .control-panel {
    padding: 8px 0 12px;
  }
}

@media (max-height: 500px) {
  .app-header {
    padding: 4px 8px;
  }
  
  .status-panel {
    padding: 4px 8px;
  }
  
  .transcript-area {
    min-height: 60px;
    max-height: 100px;
  }
  
  .control-panel {
    padding: 6px 0 8px;
  }
  
  .record-btn, .stop-btn {
    min-height: 50px;
    padding: 8px;
  }
}
