/* amlich — style.css v1.2 */
/* Theme hoàn toàn qua class html.dark — không dùng @media prefers-color-scheme */
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}

/* ── LIGHT MODE (default) ────────────────────────────────────────────────── */
:root{
  --bg:        #ffffff;
  --bg-sub:    #f8fafc;
  --bg-hover:  #f1f5f9;
  --bg-sel:    #eff6ff;
  --bg-input:  #ffffff;
  --bg-tag:    #f1f5f9;

  --border:    #e2e8f0;
  --border-md: #cbd5e1;
  --border-sel:#3b82f6;

  --text:      #0f172a;
  --text-2:    #1e293b;
  --text-3:    #334155;
  --text-4:    #475569;
  --text-5:    #64748b;
  --text-dim:  #94a3b8;

  --accent:    #3b82f6;
  --accent-dk: #2563eb;
  --green:     #16a34a;
  --amber:     #b45309;
  --radius:    6px;
}

/* ── DARK MODE — chỉ qua class html.dark ────────────────────────────────── */
html.dark{
  --bg:        #111827;
  --bg-sub:    #1f2937;
  --bg-hover:  #1f2937;
  --bg-sel:    #1e3a5f;
  --bg-input:  #1f2937;
  --bg-tag:    #1f2937;

  --border:    rgba(255,255,255,0.08);
  --border-md: rgba(255,255,255,0.15);
  --border-sel:#93c5fd;

  --text:      #f1f5f9;
  --text-2:    #e2e8f0;
  --text-3:    #cbd5e1;
  --text-4:    #94a3b8;
  --text-5:    #64748b;
  --text-dim:  #4b5563;

  --accent:    #60a5fa;
  --accent-dk: #93c5fd;
}

/* ── BASE ─────────────────────────────────────────────────────────────────── */
body{
  font-family:system-ui,-apple-system,sans-serif;
  background:var(--bg);color:var(--text);
  transition:background .2s,color .2s;
}

/* ── LAYOUT ───────────────────────────────────────────────────────────────── */
.app{display:grid;grid-template-columns:1fr 1fr;min-height:100vh}

.panel-cal{
  padding:1.5rem;
  border-right:1px solid var(--border);
  display:flex;flex-direction:column;
}
.panel-detail{
  padding:2rem;
  display:flex;flex-direction:column;
  justify-content:center;align-items:center;
  text-align:center;
}

@media(max-width:600px){
  .app{grid-template-columns:1fr;min-height:100vh}
  .panel-cal{border-right:none;border-top:1px solid var(--border);order:2}
  .panel-detail{order:1;justify-content:flex-start;padding:1.5rem}
}

/* ── DETAIL PANEL ─────────────────────────────────────────────────────────── */
.detail-solar{font-size:13px;color:var(--text-5);margin-bottom:4px;font-weight:500}
.detail-lunar{font-size:36px;font-weight:600;line-height:1.2;margin-bottom:6px;color:var(--text)}
.detail-year{font-size:15px;color:var(--text-4);margin-bottom:20px;font-weight:500}

.detail-cc{
  display:grid;grid-template-columns:repeat(3,1fr);
  gap:12px 20px;margin-bottom:24px;
  width:100%;max-width:320px;
}
.d-label{font-size:11px;color:var(--text-5);margin-bottom:3px;font-weight:500}
.d-val{font-size:14px;font-weight:600;color:var(--text-2)}

.gio-row{display:flex;flex-direction:column;align-items:center;gap:10px;width:100%;max-width:360px}
.gio-label{font-size:11px;color:var(--text-5);font-weight:500}
.gio-wrap{display:flex;flex-wrap:wrap;gap:6px;justify-content:center}
.gio-tag{
  font-size:11px;padding:4px 10px;
  background:var(--bg-tag);border:1px solid var(--border);
  border-radius:var(--radius);color:var(--text-3);font-weight:500;
}

.leap-badge{font-size:10px;color:var(--amber);margin-left:4px;font-weight:600}

/* ── TOOLBAR ──────────────────────────────────────────────────────────────── */
.toolbar{display:flex;align-items:center;gap:8px;margin-bottom:1rem}

.toolbar input[type=date]{
  font-size:12px;padding:4px 8px;height:28px;
  flex:1;min-width:0;
  border:1px solid var(--border-md);border-radius:var(--radius);
  background:var(--bg-input);color:var(--text);outline:none;
  transition:border-color .15s;
}
.toolbar input[type=date]:focus{border-color:var(--accent)}

.btn-today{
  font-size:12px;padding:0 12px;height:28px;white-space:nowrap;
  border:1px solid var(--border-md);border-radius:var(--radius);
  background:var(--bg);color:var(--text-3);cursor:pointer;font-weight:500;
  transition:background .1s;
}
.btn-today:hover{background:var(--bg-hover)}

/* ── THEME TOGGLE ─────────────────────────────────────────────────────────── */
.btn-theme{
  width:28px;height:28px;flex-shrink:0;
  border:1px solid var(--border-md);border-radius:var(--radius);
  background:var(--bg);color:var(--text-4);cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  font-size:14px;transition:background .1s,color .1s;
}
.btn-theme:hover{background:var(--bg-hover);color:var(--text)}

/* icon: light mode → hiện sun; dark mode → hiện moon */
#icon-sun { display:inline-flex }
#icon-moon{ display:none }
html.dark #icon-sun { display:none }
html.dark #icon-moon{ display:inline-flex }

/* ── NAV ──────────────────────────────────────────────────────────────────── */
.nav{display:flex;align-items:center;justify-content:space-between;margin-bottom:0.75rem}
.nav-title{font-size:12px;color:var(--text-3);font-weight:600}
.nav-btn{
  background:var(--bg);border:1px solid var(--border-md);border-radius:var(--radius);
  width:26px;height:26px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;color:var(--text-4);
  transition:background .1s,color .1s;
}
.nav-btn:hover{background:var(--bg-hover);color:var(--text)}

/* ── CALENDAR GRID ────────────────────────────────────────────────────────── */
.grid-head{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;margin-bottom:2px}
.grid-head span{text-align:center;font-size:11px;color:var(--text-5);padding:4px 0;font-weight:600}
.grid{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;flex:1}

.day{
  border-radius:var(--radius);padding:5px 2px;cursor:pointer;
  text-align:center;border:1px solid transparent;
  transition:background .1s;
}
.day:hover{background:var(--bg-hover)}
.day.other{opacity:0.3}
.day.today{border-color:var(--accent);background:var(--bg-sub)}
.day.today .solar{color:var(--accent);font-weight:600}
.day.selected{background:var(--bg-sel);border-color:var(--border-sel)}
.day.selected .solar{color:var(--accent-dk);font-weight:600}
.day.selected .lday{color:var(--accent-dk);font-weight:500}

.solar{font-size:13px;line-height:1.3;color:var(--text);font-weight:500}
.lday{font-size:9px;color:var(--text-5);line-height:1.3;font-weight:500}
.lday.special{color:var(--green);font-weight:600}

/* ── FOOTER ───────────────────────────────────────────────────────────────── */
.cal-footer{
  margin-top:auto;padding-top:1rem;
  display:flex;align-items:center;gap:6px;
  font-size:11px;color:var(--text-dim);
  flex-wrap:wrap;
}
.cal-footer a{color:var(--text-5);text-decoration:none;transition:color .1s}
.cal-footer a:hover{color:var(--accent)}
.cal-footer .sep{color:var(--border-md)}

/* ── LOADING / SKELETON ───────────────────────────────────────────────────── */
.detail-loading{
  display:flex;flex-direction:column;align-items:center;gap:12px;
  color:var(--text-5);font-size:13px;
}
.detail-loading .spin{
  width:20px;height:20px;
  border:2px solid var(--border);border-top-color:var(--accent);
  border-radius:50%;animation:spin .6s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

.cal-skeleton{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;flex:1}
.cal-skeleton .sk{
  height:40px;background:var(--bg-hover);
  border-radius:var(--radius);animation:pulse 1.2s ease-in-out infinite;
}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}

/* ── DESKTOP SCALE-UP ─────────────────────────────────────────────────────── */
@media(min-width:900px){
  .panel-detail{padding:3rem}
  .detail-solar{font-size:16px;margin-bottom:8px}
  .detail-lunar{font-size:54px;font-weight:700;margin-bottom:10px}
  .detail-year{font-size:18px;margin-bottom:36px}
  .detail-cc{max-width:420px;gap:16px 32px;margin-bottom:36px}
  .d-label{font-size:13px;margin-bottom:6px;letter-spacing:0.05em}
  .d-val{font-size:20px;font-weight:700}
  .gio-row{max-width:460px;gap:12px}
  .gio-label{font-size:13px}
  .gio-wrap{gap:8px}
  .gio-tag{font-size:13px;padding:6px 14px;border-radius:8px}
  .cal-footer{font-size:12px}
}

/* ── PWA INSTALL BANNER ───────────────────────────────────────────────────── */
#pwa-banner{
  position:fixed;bottom:0;left:0;right:0;z-index:999;
  background:var(--bg-sub);
  border-top:1px solid var(--border);
  padding:12px 16px 16px;
  display:flex;align-items:flex-start;gap:12px;
  box-shadow:0 -4px 16px rgba(0,0,0,.08);
  transform:translateY(100%);
  transition:transform .3s ease;
}
#pwa-banner.visible{transform:translateY(0)}

.pwa-icon{
  width:44px;height:44px;border-radius:10px;flex-shrink:0;
  background:#C0392B;display:flex;align-items:center;justify-content:center;
  font-size:20px;color:#fff;font-weight:700;font-family:system-ui,sans-serif;
}
.pwa-body{flex:1;min-width:0}
.pwa-title{font-size:14px;font-weight:600;color:var(--text);margin-bottom:3px}
.pwa-desc{font-size:12px;color:var(--text-5);line-height:1.5}
.pwa-desc b{color:var(--text-3);font-weight:600}
.pwa-actions{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}

.pwa-btn-install{
  font-size:12px;font-weight:600;padding:0 14px;height:30px;
  background:#C0392B;color:#fff;border:none;border-radius:var(--radius);
  cursor:pointer;white-space:nowrap;
}
.pwa-btn-install:hover{background:#a93226}
.pwa-btn-later{
  font-size:12px;padding:0 10px;height:30px;
  background:none;border:none;color:var(--text-5);cursor:pointer;
}
.pwa-btn-later:hover{color:var(--text)}
.pwa-btn-close{
  width:28px;height:28px;flex-shrink:0;margin-top:2px;
  background:none;border:none;cursor:pointer;
  color:var(--text-5);font-size:18px;line-height:1;
  display:flex;align-items:center;justify-content:center;
}
.pwa-btn-close:hover{color:var(--text)}

/* iOS instruction box */
.pwa-ios-steps{
  font-size:12px;color:var(--text-4);line-height:1.7;
  background:var(--bg-hover);border-radius:var(--radius);
  padding:8px 10px;margin-top:8px;
}
.pwa-ios-steps span{font-size:15px;vertical-align:-1px}
