* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --light-caramel: #fbba72;
  --bronze-spice: #ca5310;
  --autumn-ember: #bb4d00;
  --brandy: #8f250c;
  --molten-lava: #691e06;
  --primary-color: #ca5310;
  --secondary-color: #bb4d00;
  --success-color: #fbba72;
  --danger-color: #8f250c;
  --warning-color: #fbba72;
  --dark-color: #691e06;
  --light-color: #fff4e6;
  --border-color: #f3caa1;
  --shadow: 0 2px 10px rgba(105, 30, 6, 0.15);
  --shadow-lg: 0 4px 20px rgba(105, 30, 6, 0.25);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #fbba72 0%, #ca5310 30%, #bb4d00 55%, #8f250c 80%, #691e06 100%);
  min-height: 100vh;
  color: var(--dark-color);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.page {
  min-height: 100vh;
}

/* Login Page */
.login-container {
  max-width: 450px;
  margin: 80px auto;
  background: #fffaf4;
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.login-container h1 {
  text-align: center;
  color: var(--primary-color);
  margin-bottom: 10px;
  font-size: 2.5rem;
}

.subtitle {
  text-align: center;
  color: #666;
  margin-bottom: 30px;
  font-size: 1rem;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 25px;
  border-bottom: 2px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 12px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: #666;
  transition: all 0.3s;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.tab-btn:hover {
  color: var(--primary-color);
}

/* Forms */
.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--dark-color);
}

.form-group input {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--light-caramel);
  color: var(--brandy);
}

.btn-secondary:hover {
  background: #fdb06f;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background: #5b1804;
}

.error-message {
  color: var(--danger-color);
  font-size: 0.9rem;
  margin-top: 10px;
  text-align: center;
}

.telegram-info {
  margin-top: 25px;
  padding: 15px;
  background: rgba(251, 186, 114, 0.25);
  border-radius: 8px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--dark-color);
}

/* Dashboard */
.dashboard-header {
  background: rgba(255, 244, 230, 0.9);
  box-shadow: var(--shadow);
  padding: 20px 0;
  margin-bottom: 30px;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-content h1 {
  color: var(--primary-color);
  font-size: 1.8rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-welcome {
  font-weight: 600;
  color: var(--dark-color);
}

/* Dashboard Controls */
.dashboard-controls {
  max-width: 1200px;
  margin: 0 auto 30px;
  padding: 0 20px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.search-box {
  flex: 1;
  display: flex;
  gap: 10px;
  min-width: 300px;
}

.search-box input {
  flex: 1;
  padding: 10px 15px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.85);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff4e6;
  font-weight: 600;
}

.filters select {
  padding: 10px 15px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
}

/* Notes Container */
.notes-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 400px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

/* Note Card */
.note-card {
  background: #fff8f1;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all 0.3s;
  cursor: pointer;
}

.note-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.note-card .note-date {
  font-size: 0.85rem;
  color: rgba(105, 30, 6, 0.7);
  margin-bottom: 10px;
}

.note-card .note-summary {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark-color);
  margin-bottom: 12px;
  line-height: 1.5;
}

.note-card .note-snippet {
  font-size: 0.9rem;
  color: rgba(105, 30, 6, 0.85);
  margin-bottom: 12px;
  line-height: 1.5;
}

.note-card .note-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.note-category {
  display: inline-block;
  padding: 4px 10px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: 600;
}

.note-card .note-preview {
  font-size: 0.9rem;
  color: rgba(105, 30, 6, 0.75);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card .note-images {
  margin-top: 10px;
}

.note-card .note-images img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
}

/* Loading & Empty States */
.loading, .empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #fff4e6;
  font-size: 1.2rem;
}

.empty-state p {
  margin-bottom: 10px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 30px;
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 2rem;
  cursor: pointer;
  color: #666;
  transition: color 0.3s;
}

.close-btn:hover {
  color: var(--danger-color);
}

.note-detail-header {
  margin-bottom: 20px;
}

.note-detail-date {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 10px;
}

.note-detail-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.note-detail-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--molten-lava);
  margin-bottom: 10px;
  line-height: 1.4;
}

.note-detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.note-title-edit {
  background: rgba(251, 186, 114, 0.15);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 15px;
}

.note-title-edit input {
  width: 100%;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
  margin-bottom: 10px;
}

.note-title-edit input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.note-title-edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.note-detail-summary {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--dark-color);
  margin-bottom: 20px;
  line-height: 1.6;
}

.note-detail-content {
  font-size: 1rem;
  color: var(--dark-color);
  line-height: 1.8;
  margin-bottom: 20px;
  white-space: pre-wrap;
}

.note-source {
  font-size: 0.95rem;
  margin-bottom: 15px;
}

.note-source a {
  color: var(--primary-color);
  text-decoration: underline;
}

.note-detail-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.note-detail-images img {
  width: 100%;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.note-detail-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Pagination */
.pagination {
  max-width: 1200px;
  margin: 30px auto;
  padding: 0 20px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.pagination button {
  padding: 10px 15px;
  border: 2px solid white;
  background: white;
  color: var(--primary-color);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.pagination button:hover {
  background: var(--primary-color);
  color: white;
}

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

/* Responsive Design */
@media (max-width: 768px) {
  .login-container {
    margin: 40px 20px;
    padding: 30px 20px;
  }

  .header-content {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .dashboard-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 100%;
  }

  .notes-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    padding: 20px;
  }
}
