/* =========================================================
   Estudo Timer v7 — visual clean, dashboard amplo, 100% responsivo
   ========================================================= */

:root,
[data-et-theme="light"] {
  --et-bg: #ffffff;
  --et-surface: #ffffff;
  --et-surface-2: #f6f8fb;
  --et-text: #0f172a;
  --et-muted: #64748b;
  --et-border: #e5e9f0;
  --et-primary: #2563eb;
  --et-primary-text: #ffffff;
  --et-danger: #dc2626;
  --et-success: #16a34a;
  --et-warn: #d97706;
  --et-shadow: 0 10px 30px -12px rgba(15, 23, 42, .25);
  --et-overlay: rgba(15, 23, 42, .55);
}

[data-et-theme="dark"] {
  --et-bg: #0b1220;
  --et-surface: #111a2b;
  --et-surface-2: #162034;
  --et-text: #e8eefb;
  --et-muted: #93a3bd;
  --et-border: rgba(255, 255, 255, .1);
  --et-primary: #3b82f6;
  --et-primary-text: #ffffff;
  --et-danger: #f87171;
  --et-success: #4ade80;
  --et-warn: #fbbf24;
  --et-shadow: 0 12px 36px -14px rgba(0, 0, 0, .7);
  --et-overlay: rgba(2, 6, 18, .7);
}

.et-app *, .et-modal *, .et-sync *, .et-toasts * { box-sizing: border-box; }

/* ---------------- barra do cronômetro ---------------- */
.et-app {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 99990;
  font-family: inherit;
  color: var(--et-text);
}

.et-app.et-pos-bottom { bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0); }
.et-app.et-pos-top { top: 0; }

.et-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--et-surface);
  border-top: 1px solid var(--et-border);
  box-shadow: var(--et-shadow);
}

.et-app.et-pos-top .et-panel { border-top: 0; border-bottom: 1px solid var(--et-border); }

.et-clock-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }

.et-clock {
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1;
}

.et-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--et-muted); flex-shrink: 0; }
.et-app.is-running .et-dot { background: var(--et-success); animation: et-pulse 1.6s ease-out infinite; }
.et-app.is-paused .et-dot { background: var(--et-warn); }

@keyframes et-pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); }
  100% { box-shadow: 0 0 0 10px rgba(22, 163, 74, 0); }
}

.et-meta { display: flex; flex-direction: column; min-width: 0; font-size: 12px; color: var(--et-muted); }
.et-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.et-actions { display: flex; gap: 8px; margin-left: auto; flex-shrink: 0; }

.et-btn {
  appearance: none;
  border: 1px solid var(--et-border);
  background: var(--et-surface-2);
  color: var(--et-text);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease, background .12s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
}
.et-btn:hover { transform: translateY(-1px); }
.et-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.et-btn-primary { background: var(--et-primary); border-color: var(--et-primary); color: var(--et-primary-text); }
.et-btn-danger { background: transparent; border-color: var(--et-danger); color: var(--et-danger); }
.et-btn-icon { padding: 9px 11px; font-size: 15px; }
.et-btn-sm { padding: 7px 12px; font-size: 13px; min-height: 32px; }

.et-icon-btn {
  border: 0; background: transparent; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 6px; border-radius: 8px;
  color: var(--et-muted);
}
.et-icon-btn:hover { background: rgba(127,127,127,.14); color: var(--et-danger); }

.et-msg { margin: 0; padding: 0 16px 8px; font-size: 13px; background: var(--et-surface); }
.et-msg:empty { display: none; }

/* modo tela cheia */
.et-app[data-mode="full"] {
  inset: 0;
  background: var(--et-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.et-app[data-mode="full"] .et-panel {
  flex-direction: column;
  gap: 24px;
  border: 0;
  box-shadow: none;
  background: transparent;
  text-align: center;
  width: 100%;
}
.et-app[data-mode="full"] .et-clock { font-size: clamp(56px, 18vw, 150px); }
.et-app[data-mode="full"] .et-actions { margin-left: 0; flex-wrap: wrap; justify-content: center; }
body.et-full-open { overflow: hidden; }

/* ---------------- indicador de sincronização ---------------- */
.et-sync {
  position: fixed; z-index: 99993;
  left: 16px; bottom: 84px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--et-surface); color: var(--et-text);
  border: 1px solid var(--et-border);
  box-shadow: var(--et-shadow);
  font-size: 12px; font-weight: 600;
}
.et-sync[hidden] { display: none; }
.et-sync.is-offline { border-color: var(--et-warn); color: var(--et-warn); }
.et-sync-spin {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--et-border); border-top-color: var(--et-primary);
  animation: et-spin .8s linear infinite;
}
@keyframes et-spin { to { transform: rotate(360deg); } }

/* ---------------- toasts ---------------- */
.et-toasts {
  position: fixed; z-index: 100001;
  right: 16px; bottom: 84px;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.et-toast {
  background: var(--et-surface); color: var(--et-text);
  border: 1px solid var(--et-border); border-left: 4px solid var(--et-primary);
  border-radius: 12px; padding: 11px 14px;
  font-size: 13px; font-weight: 600;
  box-shadow: var(--et-shadow);
  animation: et-toast-in .22s ease;
}
.et-toast.is-ok { border-left-color: var(--et-success); }
.et-toast.is-err { border-left-color: var(--et-danger); }
.et-toast.is-out { opacity: 0; transform: translateY(6px); transition: all .35s ease; }
@keyframes et-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- modais ---------------- */
.et-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--et-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.et-modal[hidden] { display: none; }
body.et-modal-open { overflow: hidden; }

.et-modal-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--et-surface);
  color: var(--et-text);
  border: 1px solid var(--et-border);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--et-shadow);
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.et-modal-card-sm { max-width: 420px; }

.et-modal-card h3 { margin: 0 0 4px; font-size: 19px; font-weight: 700; }
.et-modal-sub { margin: 0 0 14px; font-size: 13px; color: var(--et-muted); }

.et-modal-time {
  margin: 0 0 18px;
  text-align: center;
  font-size: 38px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.et-modal-close {
  position: absolute; top: 10px; right: 12px;
  border: 0; background: transparent; color: var(--et-muted);
  font-size: 26px; line-height: 1; cursor: pointer;
  width: 36px; height: 36px; border-radius: 10px;
}
.et-modal-close:hover { background: rgba(127,127,127,.12); }

.et-field { margin-bottom: 14px; }
.et-field label,
.et-label-row label {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--et-muted); margin-bottom: 6px;
}
.et-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.et-link {
  border: 0; background: transparent; color: var(--et-primary);
  font-size: 12px; font-weight: 600; cursor: pointer; padding: 0 0 6px;
}

.et-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--et-surface-2);
  border: 1px solid var(--et-border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 16px; /* evita zoom automático no iOS */
  color: var(--et-text);
  outline: none;
}
@media (min-width: 721px) { .et-input { font-size: 14px; } }
.et-input:focus { border-color: var(--et-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .16); }
.et-input-sm { padding: 7px 10px; font-size: 13px; width: auto; }

.et-inline-new { display: flex; gap: 8px; margin-top: 8px; }
.et-inline-new .et-input { flex: 1; }

.et-hint { display: block; margin-top: 6px; font-size: 11px; color: var(--et-muted); }
.et-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.et-modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.et-modal-actions .et-btn { flex: 1; }

.et-tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--et-surface-2); padding: 4px; border-radius: 12px; }
.et-tab {
  flex: 1; border: 0; background: transparent; color: var(--et-muted);
  padding: 10px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.et-tab.is-active { background: var(--et-surface); color: var(--et-text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.et-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--et-muted); }
.et-auth-msg { margin: 12px 0 0; font-size: 13px; color: var(--et-danger); min-height: 18px; }
.et-auth-msg.is-ok { color: var(--et-success); }
.et-auth-msg.is-err { color: var(--et-danger); }

/* ---------------- dashboard (amplo) ---------------- */
.et-modal-wide { padding: 16px; }
.et-modal-card-lg {
  max-width: min(1520px, 96vw);
  width: 100%;
  max-height: 94vh;
  overflow-y: auto;
  padding: 26px 30px 34px;
}

.et-dash { color: var(--et-text); font-size: 15px; }
.et-dash.is-loading { opacity: .65; }

.et-dash-head {
  display: flex; flex-wrap: wrap;
  align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
  padding-right: 40px;
}
.et-dash-title { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.et-dash-title strong { font-weight: 800; }
.et-dash-sub { margin: 4px 0 0; font-size: 13px; color: var(--et-muted); }

.et-dash-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.et-chips { display: flex; gap: 6px; background: var(--et-surface-2); padding: 4px; border-radius: 12px; }
.et-chip {
  border: 0; background: transparent; color: var(--et-muted);
  padding: 8px 13px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.et-chip.is-active { background: var(--et-surface); color: var(--et-text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.et-chips-sm .et-chip { padding: 5px 10px; font-size: 12px; }

.et-dates { display: flex; align-items: center; gap: 8px; }
.et-dash-sep { font-size: 12px; color: var(--et-muted); }
.et-dash-buttons { display: flex; gap: 8px; }

/* topo: meta + cartões lado a lado, aproveitando a largura */
.et-dash-top {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 18px;
  margin-bottom: 24px;
  align-items: start;
}

.et-goal-card {
  background: var(--et-surface);
  border: 1px solid var(--et-border);
  border-radius: 16px;
  padding: 18px;
}
.et-goal-info { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.et-goal-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--et-muted); }
.et-goal-info strong { font-size: 16px; }
.et-goal-editor { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.et-progress { height: 10px; border-radius: 999px; background: var(--et-surface-2); overflow: hidden; }
.et-progress-fill { height: 100%; width: 0; background: var(--et-primary); border-radius: 999px; transition: width .4s ease; }
.et-progress-fill.is-done { background: var(--et-success); }
.et-goal-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--et-muted); }
.et-streak { font-weight: 600; color: var(--et-text); }
.et-goal-prefs {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--et-border);
}

.et-dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.et-card {
  background: var(--et-surface);
  border: 1px solid var(--et-border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.et-card-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--et-muted); }
.et-card-value { font-size: 22px; font-weight: 700; }

.et-dash-section { margin-bottom: 26px; min-width: 0; }
.et-dash-section h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.et-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.et-section-head h3 { margin: 0; }
.et-dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }

.et-chart {
  background: var(--et-surface);
  border: 1px solid var(--et-border);
  border-radius: 14px;
  padding: 16px;
}
.et-chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 200px; }
.et-chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 4px; }
.et-chart-bar { width: 100%; background: var(--et-primary); border-radius: 4px 4px 0 0; opacity: .9; transition: height .3s ease; }
.et-chart-bar.is-done { background: var(--et-success); }
.et-chart-x { font-size: 9px; color: var(--et-muted); margin-top: 6px; white-space: nowrap; height: 12px; }

.et-bar-row { margin-bottom: 14px; }
.et-bar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 6px; }
.et-bar-top small { color: var(--et-muted); white-space: nowrap; }
.et-bar-track { height: 8px; background: var(--et-surface-2); border-radius: 999px; overflow: hidden; }
.et-bar-fill { height: 100%; background: var(--et-primary); border-radius: 999px; }

.et-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.et-history-wrap { max-height: 520px; overflow-y: auto; }
.et-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.et-table th, .et-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--et-border); vertical-align: middle; }
.et-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--et-muted); font-weight: 700;
  position: sticky; top: 0; z-index: 1;
  background: var(--et-surface);
}
.et-table tbody tr:hover { background: var(--et-surface-2); }
.et-table-rank tr.is-me { background: rgba(37, 99, 235, .08); font-weight: 600; }

.et-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--et-primary); color: #fff;
}
.et-tag-ok { background: var(--et-success); }
.et-late { color: var(--et-warn); font-weight: 700; }

.et-empty { color: var(--et-muted); font-size: 14px; margin: 0; padding: 8px 0; }
.et-dash-cta { margin: 16px 0; }
.et-muted { color: var(--et-muted); }

.et-lesson-btn { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: var(--et-primary); font-weight: 600; }
.et-review-cell { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.et-review-date { max-width: 150px; }
.et-review-date[hidden] { display: none; }

/* ---------------- menu do usuário ---------------- */
.et-user { position: relative; display: inline-flex; }
.et-btn-user { position: relative; }
.et-btn-user.is-logged { color: var(--et-primary); }
.et-user-dot {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--et-success); box-shadow: 0 0 0 2px var(--et-surface);
}
.et-user-menu {
  position: absolute; right: 0; bottom: calc(100% + 10px);
  min-width: 220px; z-index: 100000;
  background: var(--et-surface);
  border: 1px solid var(--et-border);
  border-radius: 14px; padding: 8px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
}
.et-pos-top .et-user-menu { bottom: auto; top: calc(100% + 10px); }
.et-user-name {
  margin: 4px 8px 8px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--et-muted);
}
.et-user-item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; cursor: pointer;
  padding: 11px 10px; border-radius: 10px;
  font-size: 14px; color: var(--et-text);
}
.et-user-item:hover { background: var(--et-surface-2); }
.et-user-item-danger { color: var(--et-danger); }

/* ---------------- senha / login ---------------- */
.et-pass-wrap { position: relative; display: block; }
.et-pass-wrap .et-input { padding-right: 44px; }
.et-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: none; border: 0; cursor: pointer; color: var(--et-muted); border-radius: 8px;
}
.et-eye:hover { background: rgba(127,127,127,.12); }
.et-eye.is-on { color: var(--et-primary); }
.et-auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 4px; }

/* ---------------- link da aula ---------------- */
.et-lesson-card { display: flex; flex-direction: column; gap: 12px; }
.et-lesson-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-right: 40px; }
.et-lesson-head h3 { margin: 0; font-size: 17px; }
.et-lesson-frame { position: relative; width: 100%; height: min(72vh, 680px); border-radius: 12px; overflow: hidden; background: var(--et-surface-2); }
.et-lesson-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------------- responsivo ---------------- */
@media (max-width: 1180px) {
  .et-dash-top { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .et-dash-grid { grid-template-columns: 1fr; gap: 8px; }
  .et-modal-card-lg { padding: 22px 20px 28px; }
}

@media (max-width: 720px) {
  .et-panel { flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; }
  .et-clock { font-size: 24px; }
  .et-meta { font-size: 11px; flex: 1; }
  .et-actions { width: 100%; margin-left: 0; }
  .et-actions .et-btn { flex: 1; padding: 12px 8px; min-height: 44px; }
  .et-actions .et-btn-icon { flex: 0 0 auto; min-width: 46px; }

  .et-sync { left: 12px; right: 12px; bottom: auto; top: 12px; justify-content: center; }
  .et-app.et-pos-top ~ .et-sync { top: auto; bottom: 12px; }
  .et-toasts { right: 12px; left: 12px; bottom: auto; top: 12px; max-width: none; }

  .et-dash-head { flex-direction: column; align-items: stretch; padding-right: 34px; }
  .et-dash-title { font-size: 21px; }
  .et-dash-tools { flex-direction: column; align-items: stretch; }
  .et-chips { overflow-x: auto; }
  .et-chip { flex: 1; white-space: nowrap; }
  .et-dates { justify-content: space-between; }
  .et-dates .et-input-sm { flex: 1; min-width: 0; }
  .et-dash-buttons .et-btn { flex: 1; }
  .et-dash-cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .et-card-value { font-size: 19px; }

  .et-modal { align-items: flex-end; padding: 0; }
  .et-modal-card,
  .et-modal-card-lg { max-width: none; border-radius: 18px 18px 0 0; max-height: 94vh; padding: 22px 16px 28px; }
  .et-modal-wide { padding: 0; align-items: flex-end; }
  .et-modal-time { font-size: 32px; }
  .et-modal-actions { position: sticky; bottom: 0; background: var(--et-surface); padding-top: 10px; }

  .et-chart-bars { height: 150px; }
  .et-chart-x { display: none; }
  .et-history-wrap { max-height: none; }
  .et-user-menu { right: auto; left: 0; min-width: 210px; }
  .et-section-head { flex-direction: column; align-items: stretch; }
  .et-lesson-frame { height: 58vh; }
  .et-review-date { max-width: 100%; width: 100%; }

  /* tabelas viram cartões no mobile */
  .et-table thead { display: none; }
  .et-table, .et-table tbody, .et-table tr, .et-table td { display: block; width: 100%; }
  .et-table tr {
    border: 1px solid var(--et-border);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: var(--et-surface);
  }
  .et-table td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .et-table td:empty { display: none; }
  .et-table td::before {
    content: attr(data-l);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--et-muted);
    font-weight: 700;
    text-align: left;
    flex: 0 0 auto;
  }
  .et-table td .et-review-cell { align-items: flex-end; }
}

@media (max-width: 380px) {
  .et-clock { font-size: 21px; }
  .et-actions .et-btn { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .et-app.is-running .et-dot { animation: none; }
  .et-btn:hover { transform: none; }
  .et-sync-spin { animation: none; }
}

@media print {
  .et-app, .et-modal, .et-sync, .et-toasts, .et-dash-tools, .et-goal-editor { display: none !important; }
}

/* ---- v8: barra sem menu de usuário, dashboard em página ---- */
.et-btn-ghost {
  background: transparent;
  border: 1px solid var(--et-border);
  color: var(--et-text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.et-btn-ghost:hover { background: var(--et-surface-2); }
.et-btn-studies { font-weight: 600; }
.et-btn-auth.is-logged { border-color: var(--et-danger); color: var(--et-danger); }

.et-dash-page {
  width: 100%;
  max-width: 1520px;
  margin: 0 auto;
}
.et-dash-page .et-dash { padding: 0; }

@media (max-width: 640px) {
  .et-btn-studies, .et-btn-auth { flex: 1 1 auto; justify-content: center; min-height: 44px; }
}
