/* ============================================================
   MyCodex Lite 1.7 – style.css
   Minimalist purple-gradient responsive design with mobile UX
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --clr-bg:        #0f0e17;
  --clr-surface:   #1a1a2e;
  --clr-card:      #16213e;
  --clr-border:    #2a2a4a;
  --clr-primary:   #7c3aed;
  --clr-primary-h: #9333ea;
  --clr-accent:    #a78bfa;
  --clr-text:      #e2e8f0;
  --clr-muted:     #94a3b8;
  --clr-code-bg:   #1e1b4b;
  --radius:        0.75rem;
  --shadow:        0 4px 24px rgba(124, 58, 237, 0.15);
  --transition:    0.2s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  position: static !important;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(135deg, #1e1b4b 0%, #4c1d95 50%, #7c3aed 100%);
  padding: 1.5rem 2rem;
  box-shadow: 0 2px 16px rgba(124, 58, 237, 0.4);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.site-title .accent {
  color: var(--clr-accent);
}

.site-version {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
  letter-spacing: 0.05em;
}

.site-clock {
  margin-left: auto;
  font-size: 0.85rem;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.25);
  padding: 0.3rem 0.75rem;
  border-radius: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: color 0.3s ease;
}

.site-clock:empty::before {
  content: '––/––/–––– ––:––';
  opacity: 0.4;
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ---------- Cards ---------- */
.card {
  background: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--clr-accent);
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
}

.section-desc {
  font-size: 0.875rem;
  color: var(--clr-muted);
  margin-bottom: 1rem;
}

.section-desc code {
  background: var(--clr-code-bg);
  color: var(--clr-accent);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.82em;
}

/* ---------- Entries List ---------- */
.entries-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.entries-list.loaded .entry-item {
  opacity: 1;
  transform: translateY(0);
}

.entry-item {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}

.entries-list li {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: 0.5rem;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: border-color var(--transition), background var(--transition);
}

.entries-list li::before {
  content: '📄';
  font-size: 0.9em;
  flex-shrink: 0;
}

.entries-list li:hover {
  border-color: var(--clr-primary);
  background: #1e1b4b;
}

.entry-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
  transform: translateX(2px);
}

.entries-list .entry-placeholder,
.entries-list .entry-error {
  color: var(--clr-muted);
  font-style: italic;
  border-style: dashed;
}

.entries-list .entry-error {
  color: #f87171;
}

.entries-list .entry-error::before {
  content: '⚠️';
}

.entries-stats {
  font-size: 0.85rem;
  color: var(--clr-muted);
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.entries-stats strong {
  color: var(--clr-accent);
  font-weight: 600;
}

.entries-stats em {
  color: var(--clr-text);
  font-style: normal;
}

.entry-group-heading {
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.25);
  color: var(--clr-accent);
  font-weight: 700;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
}

.entry-item {
  flex-direction: column;
  align-items: flex-start;
}

.entry-meta {
  color: var(--clr-muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 0.55rem;
}

.entry-preview {
  color: var(--clr-text);
  font-size: 0.9rem;
  line-height: 1.4;
}

.entry-path {
  color: var(--clr-muted);
  font-size: 0.78rem;
  font-family: 'Courier New', monospace;
  opacity: 0.7;
  margin: 0.1rem 0 0.3rem;
  display: block;
}

.folder-status {
  margin: 0.75rem 0 1rem;
  color: var(--clr-text);
  font-size: 0.95rem;
}

.folder-status-error {
  color: #f87171;
}

.safari-warning-show {
  display: block;
}

/* ---------- Buttons ---------- */
.btn-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

button {
  transition: transform 0.1s ease-out;
}

button:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-h));
  color: #fff;
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--clr-primary-h), #a855f7);
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--clr-surface);
  color: var(--clr-accent);
  border: 1px solid var(--clr-border);
}

.btn-secondary:hover {
  background: #1e1b4b;
  border-color: var(--clr-accent);
  transform: translateY(-1px);
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 1.25rem;
  font-size: 0.8rem;
  color: var(--clr-muted);
  border-top: 1px solid var(--clr-border);
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .site-header {
    padding: 1rem 1.25rem;
  }

  .site-title {
    font-size: 1.35rem;
  }

  .card {
    padding: 1.25rem;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ---------- Editor Styles ---------- */
#editor-section {
  /* Inherits from .card */
}

#new-entry-btn {
  margin-bottom: 1rem;
}

#editor-panel {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  display: block;
}

.editor-hidden {
  display: none !important;
}


.editor-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.editor-form label {
  font-weight: 600;
  color: var(--clr-text);
}



/* ── Edytor — pola tekstowe (Galaxy dark theme) ─────────────────────────── */

#title-input,
#filename-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.75rem;
  background: var(--clr-surface);
  color: var(--clr-text);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  caret-color: var(--clr-accent);        /* widoczny kursor */
  outline: none;
}

#title-input:focus,
#filename-input:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.25);
}

#editor-textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--clr-surface);
  color: var(--clr-text);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 280px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  caret-color: #c4b5fd;                  /* fioletowy kursor — widoczny */
  outline: none;
}

#editor-textarea:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.25);
}

/* Tryb readonly — przyciemnione, kursor blokujący */
#title-input[readonly],
#filename-input[readonly],
#editor-textarea[readonly] {
  opacity: 0.72;
  cursor: default;
  background: rgba(30, 27, 75, 0.6);
}

/* Tryb edycji — pełna jasność */
#title-input:not([readonly]),
#filename-input:not([readonly]),
#editor-textarea:not([readonly]) {
  opacity: 1;
  cursor: text;
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.35);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.preview-section {
  border-top: 1px solid var(--clr-border);
  padding-top: 1rem;
}

.preview-section h4 {
  font-size: 1rem;
  color: var(--clr-accent);
  margin-bottom: 0.5rem;
}

#preview-container {
  opacity: 1;
  position: static !important;
}

.markdown-preview,
#preview {
  position: static !important;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  min-height: 120px;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.7;
  color: var(--clr-text);
}

.preview-title {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--clr-muted);
  margin-bottom: 0.75rem;
}

/* Markdown element styles inside preview */
#preview h1, #preview h2, #preview h3,
#preview h4, #preview h5, #preview h6 {
  color: var(--clr-accent);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}
#preview h1 { font-size: 1.6rem; border-bottom: 1px solid var(--clr-border); padding-bottom: 0.3rem; }
#preview h2 { font-size: 1.35rem; border-bottom: 1px solid var(--clr-border); padding-bottom: 0.2rem; }
#preview h3 { font-size: 1.15rem; }
#preview h4 { font-size: 1rem; }
#preview p  { margin-bottom: 0.75rem; }
#preview br { display: block; margin-bottom: 0.4rem; }
#preview ul, #preview ol { margin-left: 1.5rem; margin-bottom: 0.75rem; }
#preview li { margin-bottom: 0.3rem; }
#preview blockquote {
  border-left: 3px solid var(--clr-primary);
  margin: 0.75rem 0;

}

.shimmer {
  height: 16px;
  margin: 6px 0;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.05) 0%,
    rgba(255,255,255,0.15) 50%,
    rgba(255,255,255,0.05) 100%
  );
  background-size: 200% 100%;
  animation: shimmerMove 1.2s infinite;
}

@keyframes shimmerMove {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

#content {
  overflow-y: auto;
  height: 100vh;
  scroll-behavior: smooth;
}

#main, #editor-area, .main-content {
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ---------- Folder Section (v1.4) ---------- */
#folder-section {
  background: var(--clr-card);
  border: 1px solid var(--clr-border);
  margin-bottom: 1.5rem;
}

#folder-section h3 {
  font-size: 1.1rem;
  color: var(--clr-accent);
  margin-bottom: 0.5rem;
}

.folder-path {
  background: #111;
  border: 2px dashed var(--clr-border);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  color: var(--clr-muted);
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-size: 0.9rem;
  font-family: monospace;
}

.folder-path:hover {
  border-color: var(--clr-accent);
  background: var(--clr-surface);
  color: var(--clr-accent);
}

#choose-folder-btn {
  margin-bottom: 0.75rem;
}

.safari-warning-hidden {
  display: none;
}

.safari-warning-show {
  display: block;
  background: #5a4a1a;
  border-left: 4px solid #f59e0b;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  color: #fcd34d;
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

/* ---------- Entry Fields (v1.4) ---------- */

#entry-filename {
  background: #0a0a14;
  color: var(--clr-muted);
  cursor: not-allowed;
  font-size: 0.85rem;
}

#entry-filename:focus {
  outline: none;
}

/* ---------- Filter Panel (v1.4) ---------- */
#filter-section {
  /* Inherits from .card */
}

#filter-section h2 {
  margin-bottom: 1rem;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-input {
  padding: 0.6rem;
  border: 1px solid var(--clr-border);
  border-radius: 0.5rem;
  background: var(--clr-surface);
  color: var(--clr-text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition);
}

.filter-input:focus {
  outline: none;
  border-color: var(--clr-primary);
  background: var(--clr-bg);
}

.filter-input::placeholder {
  color: var(--clr-muted);
}

.filter-input option {
  background: var(--clr-card);
  color: var(--clr-text);
}

#apply-filters-btn,
#clear-filters-btn {
  grid-column: auto;
}

/* Responsive for editor */
@media (max-width: 600px) {
  #editor-panel {
    padding: 0.75rem;
  }

  .editor-form {
    gap: 0.5rem;
  }

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

  .btn-group .btn {
    width: 100%;
  }
}

/* ---------- Mobile UX (v1.6) ---------- */
.mobile-view .entries-list {
  gap: 0.75rem;
}

.mobile-view .entry-item {
  padding: 1rem;
  font-size: 1rem;
}

.mobile-view .entry-meta {
  font-size: 0.9rem;
}

.mobile-view .btn {
  min-height: 44px;
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
}

.mobile-view 
.mobile-view .editor-form {
  gap: 1rem;
}

.touch-device .entry-item:hover {
  background: rgba(124, 58, 237, 0.1);
}

/* ---------- Notifications (v1.6) ---------- */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #3b82f6;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-width: 300px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.notification-success {
  background: #10b981;
}

.notification-error {
  background: #ef4444;
}

.notification-info {
  background: #3b82f6;
}

/* ---------- Scroll Containers (v1.6.4.1) ---------- */
.main-content {
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ---------- Editor Highlight UX (v1.6.4 / v1.6.4.1) ---------- */
.editor-highlight {
  animation: editorFlash 0.6s ease-out;
}

@keyframes editorFlash {
  0%   { background-color: rgba(255, 230, 120, 0.9); }
  100% { background-color: transparent; }
}
