/* static/style.css - Clean Modern Style v3 */
:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --primary-glow: rgba(99, 102, 241, 0.15);
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ========== Navigation ========== */
nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

nav a {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

nav a:hover {
  color: var(--primary);
  background: var(--primary-light);
  text-decoration: none;
}

nav a.nav-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.3px;
  padding-left: 4px;
  padding-right: 16px;
  margin-right: 4px;
  border-right: 1px solid var(--border);
  border-radius: 0;
}

nav a.nav-brand:hover {
  background: none;
  color: var(--primary);
}

nav form {
  margin-left: auto;
}

nav form button {
  font-size: 13px;
}

/* ========== Buttons ========== */
button, input[type=submit], .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary, input[type=submit] {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 2px var(--primary-glow);
}

.btn-primary:hover, input[type=submit]:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #f8fafc;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--card-bg);
  border-color: #cbd5e1;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn-delete {
  background: transparent;
  color: var(--danger);
  padding: 4px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  opacity: 0.7;
  transition: all var(--transition);
}

.btn-delete:hover {
  background: var(--danger-light);
  opacity: 1;
}

.btn-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-edit:hover {
  background: #ddd6fe;
  text-decoration: none;
}

.btn-small {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

/* ========== Forms ========== */
.form-group {
  margin-bottom: 22px;
}

form label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

form input[type="text"],
form input[type="password"],
form input[type="search"] {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  background: var(--card-bg);
  color: var(--text);
}

form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

form input::placeholder {
  color: var(--text-muted);
}

textarea {
  width: 100%;
  min-height: 600px;
  padding: 16px;
  font-family: "SF Mono", Monaco, "Cascadia Code", "Consolas", "JetBrains Mono", monospace;
  font-size: 14px;
  line-height: 1.7;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  transition: all var(--transition);
  background: var(--card-bg);
  color: var(--text);
  tab-size: 4;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea::placeholder {
  color: var(--text-muted);
}

.hint {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.btn-cancel {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-cancel:hover {
  color: var(--text);
  background: #f1f5f9;
  text-decoration: none;
}

/* ========== Login Page ========== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 40px 36px;
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  animation: loginFadeIn 0.5s ease-out;
}

@keyframes loginFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.login-logo h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

/* ========== Flash Messages ========== */
.flash {
  padding: 12px 16px;
  margin-bottom: 20px;
  background: var(--danger-light);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: #dc2626;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.flash::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #dc2626;
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.flash-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #16a34a;
}

/* ========== Notes List ========== */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.list-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.search-bar {
  margin-bottom: 20px;
}

.search-bar form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-bar input {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  padding: 10px 14px;
  font-size: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  transition: all var(--transition);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-info {
  margin-bottom: 16px;
  padding: 8px 14px;
  background: var(--primary-light);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  color: var(--primary-hover);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-info .tag {
  font-size: 13px;
  padding: 2px 10px;
  background: var(--primary);
  color: white;
  border-radius: 9999px;
}

.note-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-item {
  position: relative;
  padding: 18px 20px;
  padding-right: 80px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.note-item:hover {
  border-color: #d0d5dd;
  box-shadow: var(--shadow-md);
  border-left-color: var(--primary);
  transform: translateX(2px);
}

.note-item .actions {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  z-index: 10;
}

.note-item .actions form {
  display: inline;
}

.note-item .btn-edit,
.note-item .btn-delete {
  position: relative;
  z-index: 20;
  background: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.note-item .btn-edit:hover {
  background: #ddd6fe;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.note-item .btn-delete:hover {
  background: #fecaca;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.note-item h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}
.note-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
}

.timestamp {
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-muted);
}

/* Tags */
.tags {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 9999px;
  transition: all var(--transition);
}

.tag:hover {
  background: #c7d2fe;
  text-decoration: none;
  transform: scale(1.05);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  background: var(--card-bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  margin: 0 0 8px 0;
  font-size: 16px;
}

.empty-state .sub-text {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ========== View Note ========== */
.note-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.note-header h1 {
  margin: 0 0 12px 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.3;
}

.note-header .note-meta {
  margin-top: 0;
}

.view-toggle {
  display: inline-flex;
  gap: 0;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f8fafc;
}

.view-toggle button {
  padding: 8px 20px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.view-toggle button:last-child {
  border-right: none;
}

.view-toggle button:hover {
  background: var(--card-bg);
  color: var(--text);
}

.view-toggle button.active {
  background: var(--card-bg);
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--primary);
}

.rendered-content {
  padding: 28px 32px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  line-height: 1.75;
}

.rendered-content h1,
.rendered-content h2,
.rendered-content h3 {
  margin-top: 28px;
  margin-bottom: 12px;
  font-weight: 700;
  color: var(--text);
}

.rendered-content h1:first-child,
.rendered-content h2:first-child,
.rendered-content h3:first-child {
  margin-top: 0;
}

.rendered-content h1 { font-size: 24px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.rendered-content h2 { font-size: 20px; }
.rendered-content h3 { font-size: 17px; }

.rendered-content p {
  margin: 0 0 16px 0;
}

.rendered-content pre {
  padding: 16px 20px;
  background: #1e293b;
  border: none;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  color: #e2e8f0;
}

.rendered-content code {
  padding: 2px 6px;
  background: #f1f5f9;
  border-radius: 4px;
  font-size: 0.9em;
  color: #e11d48;
}

.rendered-content pre code {
  padding: 0;
  background: none;
  border-radius: 0;
  color: inherit;
}

.rendered-content blockquote {
  margin: 0 0 16px 0;
  padding: 12px 20px;
  border-left: 3px solid var(--primary);
  background: #f8fafc;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.rendered-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 16px;
  font-size: 14px;
}

.rendered-content th,
.rendered-content td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

.rendered-content th {
  background: #f8fafc;
  font-weight: 600;
}

.rendered-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 16px 0;
}

.rendered-content ul,
.rendered-content ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.rendered-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

#source {
  padding: 24px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-family: "SF Mono", Monaco, "Cascadia Code", "Consolas", "JetBrains Mono", monospace;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text);
}

/* ========== Edit Form ========== */
.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}

.edit-form {
  background: var(--card-bg);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.edit-form .form-group:last-of-type {
  margin-bottom: 0;
}

/* ========== Upload Area (future use) ========== */
/* ========== Responsive ========== */
@media (max-width: 600px) {
  body {
    padding: 12px;
  }

  nav {
    padding: 8px 12px;
    gap: 2px;
  }

  nav a {
    padding: 5px 10px;
    font-size: 13px;
  }

  nav a.nav-brand {
    padding-left: 2px;
    padding-right: 10px;
    font-size: 15px;
  }

  nav form button {
    font-size: 12px;
    padding: 5px 10px;
  }

  .search-bar input {
    min-width: 100%;
    max-width: 100%;
  }

  .note-item {
    padding: 14px 16px;
    padding-right: 16px;
  }

  .note-item .actions {
    position: static;
    transform: none;
    opacity: 1;
    margin-top: 10px;
  }

  .note-item:hover {
    transform: none;
  }

  .edit-form {
    padding: 16px;
  }

  textarea {
    min-height: 400px;
  }

  .login-container {
    padding: 28px 24px;
  }

  .rendered-content {
    padding: 20px;
  }

  .note-header h1 {
    font-size: 22px;
  }

  .view-toggle button {
    padding: 6px 14px;
    font-size: 12px;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions a {
    text-align: center;
  }
}

/* ========== Tags Home Page ========== */
.tags-home {
  margin-top: 20px;
}

.tags-home h2 {
  margin: 0 0 20px 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.tag-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.tag-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tag-card .tag-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.tag-card .tag-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 9999px;
}

.tag-card:hover .tag-name {
  color: var(--primary);
}

.tag-card:hover .tag-count {
  background: var(--primary);
  color: white;
}

@media (max-width: 600px) {
  .tags-grid {
    grid-template-columns: 1fr;
  }
  
  .tag-card {
    padding: 14px 16px;
  }
}
