/* styles.css — ChronApp full styling (Context.md color scheme + Layout.md wireframes) */

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f7f8fa; color: #1a202c; line-height: 1.5; }
a { color: #3182ce; text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: 0.95rem; }

/* === Login Page === */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { width: 100%; max-width: 400px; padding: 1rem; }
.login-box { background: #fff; padding: 2.5rem 2rem; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.login-title { text-align: center; font-size: 1.4rem; margin-bottom: 1.5rem; color: #1a202c; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; color: #718096; margin-bottom: 0.3rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 0.65rem 0.75rem; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: #3182ce; box-shadow: 0 0 0 3px rgba(49,130,206,0.15);
}
.error-msg { color: #e53e3e; font-size: 0.85rem; margin-top: 0.75rem; text-align: center; }

/* === Buttons === */
.btn { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.55rem 1rem; border: none; border-radius: 8px; font-weight: 500; transition: all 0.15s; }
.btn-primary { background: #3182ce; color: #fff; }
.btn-primary:hover { background: #2b6cb0; }
.btn-admin { background: #d97706; color: #fff; }
.btn-admin:hover { background: #b45309; }
.btn-secondary { background: transparent; border: 1px solid #e2e8f0; color: #718096; }
.btn-secondary:hover { background: #f7f8fa; }
.btn-danger { background: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-toggle.active { background: #d97706; color: #fff; }

/* === Header === */
.app-header { background: #fff; border-bottom: 1px solid #e2e8f0; padding: 0.75rem 1.5rem; position: sticky; top: 0; z-index: 100; }
.header-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.header-title { font-size: 1.1rem; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.chron-select { padding: 0.35rem 0.5rem; border: 1px solid #e2e8f0; border-radius: 6px; min-width: 200px; }
.chron-info { padding: 0.4rem 0; font-size: 0.9rem; }
.chron-title { font-weight: 600; margin-right: 0.75rem; }
.chron-desc { color: #718096; margin-right: 0.75rem; }
.page-info { color: #718096; float: right; }
.admin-banner { background: #fffbeb; border-bottom: 2px solid #d97706; padding: 0.35rem 1.5rem; font-size: 0.85rem; color: #92400e; font-weight: 500; }

/* === Filter bar === */
.filter-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.5rem; background: #fff; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; }
.filter-input { flex: 1; min-width: 150px; padding: 0.4rem 0.6rem; border: 1px solid #e2e8f0; border-radius: 6px; }
.filter-select { padding: 0.4rem 0.5rem; border: 1px solid #e2e8f0; border-radius: 6px; }
.filter-date { padding: 0.4rem 0.5rem; border: 1px solid #e2e8f0; border-radius: 6px; width: 130px; }
.active-filters { padding: 0.4rem 1.5rem; font-size: 0.85rem; color: #718096; background: #fff; border-bottom: 1px solid #e2e8f0; }

/* === Events Grid (Dashboard) === */
.events-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; padding: 1.5rem; max-width: 1400px; margin: 0 auto; }
@media (max-width: 1199px) { .events-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 767px) { .events-grid { grid-template-columns: 1fr; padding: 1rem; } }

/* === Event Card === */
.event-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 1.25rem;
  border-left: 4px solid #718096; transition: box-shadow 0.2s, transform 0.2s; cursor: pointer;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.event-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-2px); }
.event-type-label { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 4px; }
.event-description { font-size: 0.9rem; color: #1a202c; flex: 1; }
.event-address { font-size: 0.8rem; color: #718096; }
.event-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: #718096; }
.event-docs { font-size: 0.8rem; }
.event-docs a { display: block; color: #3182ce; font-size: 0.8rem; padding: 0.1rem 0; }
.event-docs a:hover { text-decoration: underline; }
.event-actions { display: flex; gap: 0.3rem; }
.event-actions .btn { padding: 0.2rem 0.4rem; font-size: 0.75rem; }

/* === Empty States === */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: #718096; }
.empty-state p:first-child { font-size: 1.1rem; margin-bottom: 0.5rem; }

/* === Pagination === */
.pagination { display: flex; justify-content: center; align-items: center; gap: 0.4rem; padding: 1rem; }
.pagination button { min-width: 2rem; }
.pagination .active { background: #3182ce; color: #fff; }

/* === Admin Panel === */
.admin-section { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 1.25rem; margin: 1rem 1.5rem; }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.admin-row h2 { font-size: 1rem; }

/* === Tables === */
.table-wrap { overflow-x: auto; }
.table-wrap.collapsed { display: none; }
.collapse-toggle { background: none; border: 1px solid #d97706; color: #d97706; font-size: 0.75rem; padding: 0.2rem 0.6rem; border-radius: 4px; cursor: pointer; margin-left: 0.75rem; vertical-align: middle; }
.collapse-toggle:hover { background: #fffbeb; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th { background: #fffbeb; text-align: left; padding: 0.5rem 0.75rem; border-bottom: 2px solid #d97706; font-weight: 600; }
.admin-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.admin-table tr:hover td { background: #fefce8; }
@media (max-width: 767px) {
  .admin-table, .admin-table thead, .admin-table tbody, .admin-table th, .admin-table td, .admin-table tr { display: block; }
  .admin-table thead { display: none; }
  .admin-table td { padding: 0.3rem 0.5rem; border: none; }
  .admin-table td::before { content: attr(data-label); font-weight: 600; display: block; font-size: 0.8rem; color: #718096; }
  .admin-table tr { border-bottom: 1px solid #e2e8f0; padding: 0.5rem 0; }
}

/* === Import === */
.import-group { margin: 0.75rem 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.import-group label { font-size: 0.9rem; }
.radio-group { display: flex; gap: 0.75rem; font-size: 0.85rem; }

/* === Modal === */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 1rem; }
.modal-content { background: #fff; border-radius: 12px; padding: 1.5rem; width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 30px rgba(0,0,0,0.15); }
.modal-content h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

/* Doc list in modal */
.doc-list-item { display: flex; justify-content: space-between; align-items: center; padding: 0.3rem 0; border-bottom: 1px solid #f0f0f0; font-size: 0.85rem; }
.doc-remove-btn { background: none; border: none; color: #e53e3e; cursor: pointer; font-size: 1rem; padding: 0 0.3rem; }

/* File upload area */
.file-upload-area { border: 2px dashed #e2e8f0; border-radius: 8px; padding: 1rem; text-align: center; margin: 0.5rem 0; }
.file-list-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; font-size: 0.85rem; }
.progress-bar { width: 100%; height: 4px; background: #e2e8f0; border-radius: 2px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: #3182ce; transition: width 0.3s; }

/* === Loading === */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.8); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 300; }
.loading-overlay[hidden] { display: none; }
.spinner { width: 36px; height: 36px; border: 3px solid #e2e8f0; border-top-color: #3182ce; border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 0.5rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Toasts === */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 400; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.75rem 1rem; border-radius: 8px; color: #fff; font-size: 0.9rem; max-width: 350px; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; animation: slideIn 0.3s; }
.toast-success { background: #38a169; }
.toast-error { background: #e53e3e; }
.toast .toast-close { background: none; border: none; color: #fff; font-size: 1.1rem; cursor: pointer; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === Modal === */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 1rem; }
.modal-overlay[hidden] { display: none; }

/* === Danger zone === */
.danger-zone { background: #fef2f2; border: 1px solid #dc2626; border-radius: 8px; padding: 1rem; margin-top: 0.75rem; }

/* === Color picker in form === */
.color-preview { display: inline-block; width: 1.5rem; height: 1.5rem; border-radius: 4px; border: 1px solid #e2e8f0; vertical-align: middle; margin-left: 0.5rem; }
