/* ============================================================
   Nosso Calendário — style.css
   Base styles, design system, layout, login, modals, toasts
   ============================================================ */

/* ── Google Fonts ────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ──────────────────────────────── */
:root {
  /* Paleta principal */
  --color-bg:          #f8f7f5;
  --color-surface:     #ffffff;
  --color-surface-2:   #f3f2ef;
  --color-border:      #e8e5e0;
  --color-border-soft: #f0ede8;

  /* Texto */
  --color-text:        #1a1a1a;
  --color-text-muted:  #6b7280;
  --color-text-light:  #9ca3af;

  /* Acento principal — rose profundo, elegante */
  --color-accent:      #c2185b;
  --color-accent-soft: #fce4ec;
  --color-accent-dark: #880e4f;

  /* Usuário padrão cores */
  --color-user-1:      #1d4ed8; /* Azul — Felipe */
  --color-user-2:      #be185d; /* Rosa escuro — Jessica */

  /* Status */
  --color-success:     #059669;
  --color-warning:     #d97706;
  --color-error:       #dc2626;
  --color-info:        #2563eb;

  /* Sombras */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:   0 10px 30px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);
  --shadow-xl:   0 20px 60px rgba(0,0,0,.14);

  /* Bordas */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  /* Tipografia */
  --font:        'Inter', system-ui, -apple-system, sans-serif;

  /* Espaçamentos */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Transições */
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* Garante que o atributo hidden funcione mesmo quando CSS define display:flex/grid */
[hidden] { display: none !important; }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-light); }

/* ── Utility: Screen-reader only ────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ══════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  transition: background var(--transition), color var(--transition),
              box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(194,24,91,.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-dark);
  box-shadow: 0 4px 14px rgba(194,24,91,.35);
}

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-border); }

.btn-danger {
  background: var(--color-error);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-full { width: 100%; }

.btn-sm {
  padding: 7px var(--space-3);
  font-size: 13px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--color-surface-2); color: var(--color-text); }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.01em;
}

.form-group .required { color: var(--color-accent); }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(194,24,91,.1);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: var(--color-error);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
}

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background:
    radial-gradient(ellipse at top left,  rgba(194,24,91,.08) 0%, transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(29,78,216,.06) 0%, transparent 55%),
    var(--color-bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border-soft);
  animation: fadeInUp var(--transition-slow) both;
}

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

.login-brand {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-icon {
  font-size: 42px;
  margin-bottom: var(--space-3);
  filter: drop-shadow(0 2px 6px rgba(194,24,91,.2));
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.login-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  font-weight: 400;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-password-wrapper input {
  padding-right: 42px;
}

.btn-toggle-pw {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: opacity var(--transition);
}
.btn-toggle-pw:hover { opacity: 0.7; }

.login-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: var(--color-error);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  text-align: center;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60%  { transform: translateX(-6px); }
  40%, 80%  { transform: translateX(6px); }
}
.shake { animation: shake 0.4s ease-in-out; }

.login-hint {
  text-align: center;
  margin-top: var(--space-5);
  font-size: 12px;
  color: var(--color-text-light);
}

/* ══════════════════════════════════════════════════════════
   APP LAYOUT
   ══════════════════════════════════════════════════════════ */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: 60px;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

.topbar-icon { font-size: 22px; }

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

/* Sync indicator */
.sync-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.sync-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-ok   { background: #f0fdf4; border-color: #bbf7d0; color: var(--color-success); }
.sync-ok   .sync-dot { background: var(--color-success); }

.sync-busy { background: #fffbeb; border-color: #fde68a; color: var(--color-warning); }
.sync-busy .sync-dot { background: var(--color-warning); animation: pulse 1s ease-in-out infinite; }

.sync-err  { background: #fef2f2; border-color: #fca5a5; color: var(--color-error); }
.sync-err  .sync-dot { background: var(--color-error); }

@keyframes pulse {
  0%, 100% { opacity: 1; } 50% { opacity: 0.3; }
}

/* User area */
.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: var(--color-accent);
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

.btn-logout {
  color: var(--color-text-muted);
  transition: color var(--transition), background var(--transition);
}
.btn-logout:hover { color: var(--color-error); background: #fef2f2; }

/* ── Main layout ─────────────────────────────────────────── */
.main-layout {
  flex: 1;
  display: flex;
  gap: 0;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-6);
  gap: var(--space-6);
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sidebar-section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.sidebar-heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

/* Upcoming events */
.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.upcoming-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-accent);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.upcoming-item:hover { background: var(--color-border-soft); transform: translateX(2px); }

.upcoming-item-date {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.upcoming-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upcoming-item-time {
  font-size: 11px;
  color: var(--color-text-muted);
}

.upcoming-empty {
  font-size: 13px;
  color: var(--color-text-light);
  text-align: center;
  padding: var(--space-3) 0;
}

/* Legend */
.legend-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--color-text);
}

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Calendar container ──────────────────────────────────── */
.calendar-container {
  flex: 1;
  min-width: 0;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ══════════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  /* display controlado pela classe .is-open — nunca depende do atributo hidden */
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-overlay.is-open {
  display: flex;
  animation: fadeIn 150ms ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp var(--transition-slow) both;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-event-card { max-width: 500px; }
.modal-day-card   { max-width: 420px; }
.modal-confirm-card { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.modal-close {
  color: var(--color-text-muted);
  font-size: 16px;
}
.modal-close:hover { background: var(--color-surface-2); color: var(--color-text); }

.modal-body {
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

.modal-footer-between { justify-content: space-between; }
.modal-footer-actions { display: flex; gap: var(--space-3); }

/* Creator info inside event modal */
.event-creator-info {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.7;
  border: 1px solid var(--color-border-soft);
}

/* Day modal events */
.modal-day-content {
  padding: var(--space-4) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 60px;
}

.day-event-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid var(--color-border-soft);
}
.day-event-item:hover { background: var(--color-border-soft); }

.day-event-color-bar {
  width: 4px;
  border-radius: var(--radius-full);
  min-height: 36px;
  flex-shrink: 0;
}

.day-event-info { flex: 1; min-width: 0; }
.day-event-title { font-size: 14px; font-weight: 500; color: var(--color-text); }
.day-event-meta  { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

.day-empty-text {
  font-size: 14px;
  color: var(--color-text-light);
  text-align: center;
  padding: var(--space-4) 0;
}

/* ══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--color-text);
  color: #fff;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  max-width: 340px;
}

.toast.toast-success { background: var(--color-success); }
.toast.toast-error   { background: var(--color-error); }
.toast.toast-warning { background: var(--color-warning); }
.toast.toast-info    { background: var(--color-info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(40px) scale(0.9); }
}

.toast.removing { animation: toastOut 250ms ease forwards; }

/* List view */
.event-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.event-list-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}
.event-list-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.event-list-date {
  width: 52px;
  text-align: center;
  flex-shrink: 0;
}

.event-list-day-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
}

.event-list-day-name {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.event-list-bar {
  width: 4px;
  border-radius: var(--radius-full);
  min-height: 44px;
  flex-shrink: 0;
}

.event-list-content { flex: 1; min-width: 0; }
.event-list-title { font-size: 15px; font-weight: 600; color: var(--color-text); }
.event-list-meta  { font-size: 13px; color: var(--color-text-muted); margin-top: 3px; }

.event-list-empty {
  text-align: center;
  padding: var(--space-10) 0;
  color: var(--color-text-light);
  font-size: 15px;
}

/* View tabs */
.view-tabs {
  display: flex;
  gap: 2px;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 3px;
  width: fit-content;
}

.view-tab {
  padding: 6px var(--space-4);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}
.view-tab:hover { color: var(--color-text); }
.view-tab.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .main-layout {
    flex-direction: column;
    padding: var(--space-4);
    gap: var(--space-4);
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .sidebar-section {
    flex: 1;
    min-width: 200px;
  }

  .topbar-inner { padding: 0 var(--space-4); }
}

@media (max-width: 600px) {
  .main-layout { padding: var(--space-3); }

  .calendar-container {
    padding: var(--space-4) var(--space-3);
    border-radius: var(--radius-lg);
  }

  .modal-card {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    max-width: 100%;
    max-height: 95vh;
    animation: slideUpMobile var(--transition-slow) both;
  }

  @keyframes slideUpMobile {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .modal-overlay { align-items: flex-end; padding: 0; }

  .form-row { grid-template-columns: 1fr; }

  .sidebar { display: none; }

  .topbar-title { display: none; }

  .sync-label { display: none; }

  .user-name { display: none; }

  .toast-container {
    bottom: var(--space-4);
    left: var(--space-3);
    right: var(--space-3);
  }

  .toast { max-width: 100%; }
}
