/* ============================================
   CSS Variables - Theme Colors
   ============================================ */
:root {
  --color-primary: #6366f1;
  --color-secondary: #8b5cf6;
  --color-accent: #3b82f6;
  --color-background: #0a0a0f;
  --color-foreground: #e8e8f0;
  --color-card: #14141f;
  --color-border: rgba(99, 102, 241, 0.2);
  --color-input: rgba(99, 102, 241, 0.1);
  --color-muted: #1e1e2e;
  --color-muted-foreground: #9ca3af;
  --color-destructive: #ef4444;
}

/* ============================================
   Base Styles
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  background: linear-gradient(135deg, var(--color-background) 0%, #000000 100%);
  min-height: 100vh;
  color: var(--color-foreground);
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

/* ============================================
   Particle Background
   ============================================ */
.particle-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at top,
    #1a1a2e 0%,
    #0a0a0f 50%,
    #000000 100%
  );
  z-index: 0;
  display: block;
}

/* ============================================
   App Container
   ============================================ */
.app-container {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  backdrop-filter: blur(10px);
}

/* ============================================
   Header
   ============================================ */
.app-header {
  padding: 2.5rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  background: rgba(20, 20, 31, 0.4);
  backdrop-filter: blur(20px);
}

.header-content {
  max-width: 90rem;
  margin: 0 auto;
}

.header-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.header-title h1 {
  font-size: clamp(2rem, 10vw, 5rem);
  font-weight: 100;
  letter-spacing: -0.02em;
  background: linear-gradient(
    90deg,
    var(--color-primary),
    var(--color-secondary),
    var(--color-primary)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.status-indicator-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.8);
  animation: pulse-animation 2s ease-in-out infinite;
}

@keyframes pulse-animation {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.pulse-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--color-primary);
  animation: ping-animation 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping-animation {
  75%,
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

.header-subtitle {
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--color-muted-foreground);
  opacity: 0.6;
  font-weight: 300;
}

/* ============================================
   Main Content
   ============================================ */
.app-main {
  flex: 1;
  padding: 2rem 1rem;
  overflow-y: visible;
  overflow-x: hidden;
}

.content-grid {
  max-width: 90rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  grid-template-areas:
    "control control stats"
    "control control transcript"
    "control control transcript";
}

@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "control"
      "stats"
      "transcript";
  }
}

/* ============================================
   Control Panel
   ============================================ */
.control-panel {
  grid-area: control;
  background: rgba(20, 20, 31, 0.2);
  backdrop-filter: blur(30px);
  border: 1px solid var(--color-border);
  border-radius: 1.875rem;
  padding: 2.5rem;
  box-shadow: 0 8px 40px rgba(99, 102, 241, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.5s ease;
}

.control-panel:hover {
  box-shadow: 0 8px 60px rgba(99, 102, 241, 0.18);
}

.control-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  width: 100%;
}

/* ============================================
   Recording Circle
   ============================================ */
.recording-circle {
  width: 14rem;
  height: 14rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.1),
    rgba(139, 92, 246, 0.1)
  );
  border: 2px solid rgba(99, 102, 241, 0.2);
  transition: all 0.7s ease;
  position: relative;
}

.recording-circle.recording {
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.2),
    rgba(139, 92, 246, 0.2)
  );
  box-shadow: 0 0 80px rgba(99, 102, 241, 0.5);
  border-color: var(--color-primary);
}

.recording-circle.recording::before,
.recording-circle.recording::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--color-primary);
  opacity: 0.2;
}

.recording-circle.recording::before {
  width: 18rem;
  height: 18rem;
  animation: pulse-ring 2s ease-out infinite;
}

.recording-circle.recording::after {
  width: 22rem;
  height: 22rem;
  animation: pulse-ring 3s ease-out infinite;
}

@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.3;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

.mic-icon {
  width: 6rem;
  height: 6rem;
  color: var(--color-muted-foreground);
  opacity: 0.4;
  transition: all 0.3s ease;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.recording-circle.recording .mic-icon {
  color: var(--color-primary);
  opacity: 0.8;
  filter: drop-shadow(0 0 15px rgba(99, 102, 241, 0.8));
}

/* ============================================
   Time Display
   ============================================ */
.time-display {
  text-align: center;
  width: 100%;
}

.time-value {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 100;
  color: var(--color-foreground);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

.recording-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.status-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--color-muted-foreground);
  opacity: 0.2;
  transition: all 0.3s ease;
}

.recording-circle.recording ~ .time-display .status-dot {
  background: var(--color-primary);
  opacity: 1;
  animation: pulse-animation 1s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.8);
}

.status-text {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-muted-foreground);
  opacity: 0.8;
  font-weight: 300;
}

/* ============================================
   Button Group
   ============================================ */
.button-group {
  display: flex;
  gap: 1rem;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  flex: 1;
  min-width: 10rem;
  padding: 1.5rem 3rem;
  border: none;
  border-radius: 0.875rem;
  font-size: 1.125rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background-size: 200%;
  background-position: 0;
  overflow: hidden;
  position: relative;
}

.btn svg {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transform: translateX(-200%);
  transition: transform 1s ease;
}

.btn:hover::before {
  transform: translateX(200%);
}

.btn:hover:not(:disabled) {
  transform: scale(1.05);
}

.btn:active:not(:disabled) {
  transform: scale(0.95);
}

.btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.btn-start {
  background: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
  color: white;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.btn-start:hover:not(:disabled) {
  box-shadow: 0 0 50px rgba(99, 102, 241, 0.7);
}

.btn-stop {
  background: linear-gradient(135deg, var(--color-destructive), #dc2626);
  color: white;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.btn-stop:hover:not(:disabled) {
  box-shadow: 0 0 50px rgba(239, 68, 68, 0.7);
}

.btn-clear {
  background: var(--color-muted);
  border: 2px solid var(--color-border);
  color: var(--color-muted-foreground);
  padding: 1.375rem 2.875rem;
}

.btn-clear:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--color-primary);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.15);
}

/* ============================================
   Stats Panel
   ============================================ */
.stats-panel {
  grid-area: stats;
  background: rgba(20, 20, 31, 0.2);
  backdrop-filter: blur(30px);
  border: 1px solid var(--color-border);
  border-radius: 0.875rem;
  padding: 1.5rem;
  box-shadow: 0 4px 30px rgba(99, 102, 241, 0.1);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.stat-card {
  text-align: center;
  padding: 1rem;
  background: rgba(26, 26, 46, 0.3);
  border-radius: 0.75rem;
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.stat-value {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 300;
  color: var(--color-foreground);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-muted-foreground);
  opacity: 0.6;
  margin-top: 0.25rem;
  font-weight: 300;
}

/* ============================================
   Transcript Panel
   ============================================ */
.transcript-panel {
  grid-area: transcript;
  background: rgba(20, 20, 31, 0.2);
  backdrop-filter: blur(30px);
  border: 1px solid var(--color-border);
  border-radius: 1.875rem;
  padding: 1.5rem 2rem;
  box-shadow: 0 8px 40px rgba(99, 102, 241, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.5s ease;
  max-height: 600px;
}

@media (max-width: 768px) {
  .transcript-panel {
    max-height: 400px;
  }
}

.transcript-panel:hover {
  box-shadow: 0 8px 60px rgba(99, 102, 241, 0.18);
}

.transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.transcript-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.live-indicator {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-primary);
  animation: pulse-animation 1.5s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.8);
}

.transcript-title h3 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-muted-foreground);
  opacity: 0.8;
  font-weight: 300;
}

.transcript-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-btn {
  padding: 0.625rem;
  background: rgba(26, 26, 46, 0.4);
  border: 2px solid var(--color-border);
  border-radius: 0.5rem;
  color: var(--color-muted-foreground);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn svg {
  width: 1rem;
  height: 1rem;
}

.action-btn:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: scale(1.05);
}

.action-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.action-btn.copied {
  color: var(--color-primary);
}

.transcript-content {
  flex: 1;
  background: rgba(26, 26, 46, 0.4);
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  padding: 2rem;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 300px;
  max-height: 500px;
}

@media (max-width: 768px) {
  .transcript-content {
    min-height: 200px;
    max-height: 350px;
    padding: 1rem;
  }
}

.transcript-content::-webkit-scrollbar {
  width: 0.5rem;
}

.transcript-content::-webkit-scrollbar-track {
  background: transparent;
}

.transcript-content::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.2);
  border-radius: 0.25rem;
}

.transcript-content::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.3);
}

.transcript-text {
  color: var(--color-foreground);
  line-height: 1.75;
  font-size: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.transcript-text.buffer {
  color: var(--color-foreground);
}

.cursor {
  display: inline-block;
  width: 0.125rem;
  height: 1.5rem;
  background: var(--color-primary);
  margin-left: 0.25rem;
  animation: pulse-animation 1s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.8);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--color-muted-foreground);
  opacity: 0.4;
}

.empty-icon {
  width: 4rem;
  height: 4rem;
  margin-bottom: 1rem;
  opacity: 0.2;
}

.empty-state p {
  font-size: 1.125rem;
  font-weight: 300;
  margin-bottom: 0.5rem;
}

.empty-hint {
  font-size: 0.875rem;
  opacity: 0.6;
}

/* ============================================
   Footer
   ============================================ */
.app-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--color-border);
  background: rgba(20, 20, 31, 0.4);
  backdrop-filter: blur(20px);
  font-size: 0.75rem;
}

.footer-content {
  max-width: 90rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

@media (min-width: 640px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
  }
}

.footer-info {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-muted-foreground);
  opacity: 0.5;
  font-weight: 300;
}

.footer-credits {
  text-align: right;
  font-weight: 300;
  color: var(--color-muted-foreground);
  opacity: 0.5;
}

.credits {
  margin-top: 0.25rem;
  opacity: 0.7;
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 0.5rem;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.2);
  border-radius: 0.25rem;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.3);
}

/* Sections */
.control-section,
.transcription-section,
.log-section {
  background: #f9fafb;
  border-radius: 6px;
  padding: 20px;
  border: 1px solid #e5e7eb;
}

.control-section {
  grid-column: 1;
  grid-row: 1 / 3;
}

.transcription-section {
  grid-column: 2;
  grid-row: 1;
}

.log-section {
  grid-column: 2;
  grid-row: 2;
}

@media (max-width: 1024px) {
  .control-section {
    grid-column: 1;
    grid-row: 1;
  }
  .transcription-section {
    grid-column: 1;
    grid-row: 2;
  }
  .log-section {
    grid-column: 1;
    grid-row: 3;
  }
}

section h2 {
  color: #1a202c;
  margin-bottom: 16px;
  font-size: 1.125em;
  font-weight: 600;
}

/* Buttons */
.button-group {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  min-width: 100px;
}

.btn:hover:not(:disabled) {
  opacity: 0.9;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: #2563eb;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-success {
  background: #16a34a;
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #15803d;
}

.btn-secondary {
  background: #6b7280;
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #4b5563;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.85em;
  margin-top: 12px;
  flex: none;
  min-width: auto;
}

/* Buffer Info */
.buffer-info {
  background: white;
  padding: 16px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.9em;
}

.info-row label {
  font-weight: 500;
  color: #6b7280;
}

.info-row span {
  color: #1f2937;
  font-weight: 500;
}

.buffer-bar-container {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
}

.buffer-bar {
  height: 100%;
  background: #2563eb;
  width: 0%;
  transition: width 0.2s ease;
}

/* Transcription Output */
.transcription-output {
  background: white;
  padding: 16px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  min-height: 150px;
  font-size: 1em;
  line-height: 1.6;
  word-wrap: break-word;
  transition: border-color 0.2s ease;
  color: #374151;
}

.transcription-output:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.05);
}

.transcription-output.success {
  border-color: #16a34a;
  background: #f0fdf4;
}

.transcription-output.error {
  border-color: #ef4444;
  background: #fef2f2;
}

.placeholder {
  color: #9ca3af;
  font-style: italic;
}

.transcription-info {
  margin-top: 8px;
  font-size: 0.85em;
  color: #6b7280;
}

/* Event Log */
.event-log {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  height: 200px;
  overflow-y: auto;
  font-size: 0.85em;
  font-family: "Courier New", monospace;
}

.log-entry {
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 3px;
  border-left: 2px solid #2563eb;
  font-size: 0.9em;
}

.log-entry.info {
  background: #eff6ff;
  color: #0c4a6e;
}

.log-entry.success {
  background: #f0fdf4;
  color: #15803d;
  border-left-color: #16a34a;
}

.log-entry.error {
  background: #fef2f2;
  color: #991b1b;
  border-left-color: #ef4444;
}

.log-entry.warning {
  background: #fffbeb;
  color: #92400e;
  border-left-color: #f59e0b;
}

/* Footer */
.footer {
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  padding: 16px;
  text-align: center;
  color: #6b7280;
  font-size: 0.85em;
}

.footer code {
  background: #f3f4f6;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: "Courier New", monospace;
  color: #1f2937;
}

/* Scrollbar Styling */
.event-log::-webkit-scrollbar {
  width: 6px;
}

.event-log::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}

.event-log::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.event-log::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

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

.log-entry {
  animation: slideIn 0.2s ease;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 12px;
  }

  .header h1 {
    font-size: 1.5em;
  }

  .main-content {
    padding: 16px;
    gap: 16px;
  }

  .button-group {
    flex-direction: column;
  }

  .btn {
    min-width: auto;
  }

  .footer {
    font-size: 0.8em;
  }
}
