/* ======================================
   DAGBOK — style.css
   ====================================== */

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

:root {
  /* Neutrals */
  --bg:           #F8F7F4;
  --surface:      #FFFFFF;
  --surface-2:    #F2F1ED;
  --border:       #E5E3DD;
  --text:         #1C1B18;
  --text-muted:   #78746E;
  --text-faint:   #B0ABA4;

  /* Rating palette — dark enough for text use */
  --r5: #16A34A;   /* Jättebra — green  */
  --r4: #65A30D;   /* Bra      — lime   */
  --r3: #D97706;   /* Okej     — amber  */
  --r2: #EA580C;   /* Sådär    — orange */
  --r1: #DC2626;   /* Dålig    — red    */

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;

  /* Shape */
  --radius:    10px;
  --radius-sm: 6px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 14px rgba(0,0,0,.09);

  /* Transitions */
  --t: 0.15s ease;
}

html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ======================================
   HEADER
   ====================================== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.app-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  flex-shrink: 0;
}

.tab-nav {
  display: flex;
  gap: 3px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--t), color var(--t);
}

.tab-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tab-btn.active {
  background: var(--text);
  color: #fff;
}

/* ======================================
   VIEWS
   ====================================== */
.view { display: none; }
.view.active { display: block; }

.app-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ======================================
   HOME LAYOUT
   ====================================== */
.home-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 20px;
  align-items: start;
}

/* ======================================
   CALENDAR
   ====================================== */
.calendar-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.cal-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.cal-nav {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t), color var(--t);
  line-height: 1;
}

.cal-nav:hover {
  background: var(--surface-2);
  color: var(--text);
}

.cal-days-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 6px;
}

.cal-days-header span {
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 3px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--text);
  gap: 2px;
  transition: background var(--t);
  position: relative;
}

.cal-day:hover:not(.selected) {
  background: var(--surface-2);
}

.cal-day.other-month {
  color: var(--text-faint);
}

.cal-day.today:not(.selected) {
  font-weight: 600;
  box-shadow: inset 0 0 0 1.5px var(--text);
}

.cal-day.selected {
  background: var(--text) !important;
  color: #fff;
}

.cal-day.selected .cal-dot {
  background: rgba(255,255,255,0.7) !important;
}

.cal-day-num {
  line-height: 1;
}

.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--t);
}

.cal-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  min-height: 22px;
}

/* ======================================
   EDITOR
   ====================================== */
.editor-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-color, var(--border));
  border-radius: var(--radius);
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-left-color 0.3s ease;
}

.editor-date {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.editor-dow {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.editor-date-str {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 28px;
  color: var(--text);
  line-height: 1.2;
}

.editor-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

/* ---- Rating Selector ---- */
.rating-selector {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.rating-btn {
  padding: 10px 6px 9px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: border-color var(--t), background var(--t), color var(--t);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.rating-btn:hover {
  border-color: var(--rc);
  color: var(--rc);
  background: color-mix(in srgb, var(--rc) 7%, transparent);
}

.rating-btn.selected {
  border-color: var(--rc);
  color: var(--rc);
  background: color-mix(in srgb, var(--rc) 11%, transparent);
  font-weight: 600;
}

.rating-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rc);
  opacity: 0.45;
  flex-shrink: 0;
  transition: opacity var(--t), transform var(--t);
}

.rating-btn.selected .rating-dot {
  opacity: 1;
  transform: scale(1.2);
}

/* ---- Textarea ---- */
.description-textarea {
  width: 100%;
  min-height: 180px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  background: var(--surface);
  resize: none;
  outline: none;
  transition: border-color var(--t);
  overflow: hidden;
}

.description-textarea:focus {
  border-color: var(--text-muted);
}

.description-textarea::placeholder {
  color: var(--text-faint);
}

.char-count {
  font-size: 12px;
  color: var(--text-faint);
  text-align: right;
  margin-top: -4px;
}

/* ---- Editor Actions ---- */
.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.save-status {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.3s;
}

.save-status.visible { opacity: 1; }

/* ======================================
   BUTTONS
   ====================================== */
.btn {
  padding: 9px 22px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--t), background var(--t), color var(--t);
  border: none;
  line-height: 1;
}

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

.btn-primary {
  background: var(--text);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.82;
}

.btn-ghost {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: none;
  border: 1.5px solid color-mix(in srgb, var(--r1) 35%, var(--border));
  color: var(--r1);
}

.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--r1) 8%, transparent);
}

.btn-clear {
  width: 100%;
  text-align: center;
  justify-content: center;
  font-size: 13px;
}

.hidden { display: none !important; }

/* ======================================
   LOG LAYOUT
   ====================================== */
.log-layout {
  display: grid;
  grid-template-columns: 264px 1fr;
  gap: 20px;
  align-items: start;
}

/* ======================================
   FILTER PANEL
   ====================================== */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 74px;
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-input {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--t);
}

.search-input:focus { border-color: var(--text-muted); }
.search-input::placeholder { color: var(--text-faint); }

.rating-filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rf-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: border-color var(--t), background var(--t), color var(--t);
  text-align: left;
}

.rf-btn:hover {
  border-color: var(--rc);
  color: var(--rc);
  background: color-mix(in srgb, var(--rc) 7%, transparent);
}

.rf-btn.active {
  border-color: var(--rc);
  color: var(--rc);
  background: color-mix(in srgb, var(--rc) 11%, transparent);
}

.rf-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rc);
  flex-shrink: 0;
}

.length-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.length-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--t);
}

.length-input:focus { border-color: var(--text-muted); }
.length-input::placeholder { color: var(--text-faint); }

.length-dash { color: var(--text-faint); font-size: 13px; }

.filter-result-count {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  min-height: 16px;
}

/* ======================================
   ENTRIES LIST
   ====================================== */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rc, var(--border));
  border-radius: var(--radius);
  padding: 18px 22px;
  cursor: pointer;
  transition: box-shadow var(--t), transform var(--t);
  box-shadow: var(--shadow-sm);
}

.entry-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.entry-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.entry-card-date {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16.5px;
  color: var(--text);
  line-height: 1.2;
}

.entry-card-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--rc) 11%, transparent);
  color: var(--rc);
  flex-shrink: 0;
}

.entry-card-preview {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-card-preview em {
  color: var(--text-faint);
  font-style: italic;
}

.entry-card-meta {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-faint);
}

/* Empty state */
.entries-empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--text-muted);
}

.entries-empty h3 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 21px;
  color: var(--text);
  margin-bottom: 8px;
}

.entries-empty p {
  font-size: 14px;
}

/* ======================================
   ANIMATIONS
   ====================================== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  60%       { transform: translateX(5px); }
  80%       { transform: translateX(-3px); }
}

.shake { animation: shake 0.38s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.entry-card { animation: fade-in 0.2s ease both; }

/* ======================================
   RESPONSIVE
   ====================================== */
@media (max-width: 860px) {
  .home-layout,
  .log-layout {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    position: static;
  }

  .app-main {
    padding: 20px 16px 50px;
  }

  .header-inner {
    padding: 0 16px;
  }
}

@media (max-width: 480px) {
  .rating-btn {
    font-size: 11px;
    padding: 9px 4px;
  }

  .editor-panel {
    padding: 22px 18px;
  }

  .editor-date-str {
    font-size: 23px;
  }
}
