/* emscards.css */

/* iOS System Font */
:root {
  --ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Rounded",
              "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* iOS-y colors */
  --bg: #1f2735;
  --card: #2e3b4e;
  --card-2: #2a3442;
  --text: #e1e5eb;
  --muted: #cbd4e1;
  --divider: #4a5568;
  --accent: #0a84ff;
  --teal: #00b7ff;
  --danger: #ff3b30;

  /* Drawer */
  --drawer-bg: #151a23;
  --drawer-panel: #1f2632;
  --drawer-shadow: 0 10px 40px rgba(0,0,0,.35);
}

/* Reset & base */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--ios-font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header */
.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}
.logo {
  height: 60px;
  object-fit: contain;
}
.datetime-section { align-self: flex-end; }
.datetime {
  font-weight: 300;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  margin-top: 8px;
}

/* Overlay spinner */
.spinner-overlay {
  position: relative;
  width: 100%;
  min-height: 200px;
}
.spinner-overlay .spinner {
  position: absolute; top: 50%; left: 50%;
  width: 48px; height: 48px; margin: -24px 0 0 -24px;
  border: 5px solid rgba(0,0,0,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none; }

/* Filters bar */
.filters {
  display: flex; gap: 16px; justify-content: center; align-items: center;
  padding: 16px; background: var(--card-2);
}
.filter label { margin-right: 8px; font-size: 0.9rem; }
.filter input[type="date"], .filter select, .dropdown-toggle {
  font-family: var(--ios-font);
  padding: 8px 10px;
  margin: 0 8px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: var(--text);
}

/* Custom dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-toggle {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 8px 12px; cursor: pointer;
  min-width: 120px; text-align: left;
  transition: box-shadow .15s;
}
.dropdown-toggle:hover { box-shadow: 0 4px 18px rgba(10,132,255,0.14); }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--card-2); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; max-height: 210px; overflow-y: auto; z-index: 10; min-width: 180px;
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
}
.dropdown-item {
  padding: 8px 12px; display: flex; align-items: center; gap: 8px;
  font-size: 0.95rem; cursor: pointer;
}
.dropdown-item:hover { background: rgba(255,255,255,0.06); }
.dropdown-item input { margin-right: 4px; }

/* Cards grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  padding: 16px;
}

/* Card */
.card {
  position: relative; background: var(--card);
  border-radius: 16px; padding: 16px;
  text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 32px rgba(0, 183, 255, 0.6);
}
.card-index {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,0.6); color: #fff;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
}
.card-title { font-size: 1.1rem; font-weight: 700; margin-top: 8px; }
.card-cert { font-size: 0.9rem; font-weight: 300; color: var(--muted); margin: 8px 0; }
.ai-btn {
  padding: 8px 14px; border: none; border-radius: 20px;
  background: #000; color: var(--teal); font-weight: 700;
  cursor: pointer; letter-spacing: .01em;
}
.card-divider { border-top: 1px solid var(--divider); margin: 12px 0; }
.card-row { display: flex; justify-content: space-between; font-size: 0.95rem; margin-bottom: 8px; color: var(--text); }

/* CENTER MODAL (AI modal kept) */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-content {
  background: var(--card); padding: 24px;
  border-radius: 12px; max-width: 90%; max-height: 90%;
  overflow-y: auto; position: relative;
}
.close-btn {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; color: var(--text);
  font-size: 1.5rem; cursor: pointer;
}

/* === ResponseIQ Modal Styles (iOS Native Feel) === */
#aiModal {
  font-family: var(--ios-font);
  background: rgba(36, 37, 38, 0.97);
  border-radius: 28px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  max-width: 800px;
  margin: 32px auto;
  padding: 0;
  color: #f2f2f7;
  overflow: hidden;
  animation: fadeInModal 0.32s cubic-bezier(.4,1.7,.5,.96);
}
@keyframes fadeInModal { from { opacity: 0; transform: translateY(36px);} to { opacity: 1; transform: translateY(0);} }
#aiBody { padding: 2.2rem 1.6rem 1.4rem 1.6rem; background: rgba(34, 34, 38, 0.92); }
#aiClose {
  position: absolute; top: 0.7rem; right: 1rem;
  background: none; border: none; color: #f2f2f7;
  font-size: 1.6rem; cursor: pointer; opacity: 0.85; z-index: 20;
}
#aiClose:hover { color: #ff375f; }

/* ============================= */
/* LEFT SLIDE-OUT DRAWER (DETAIL)*/
/* ============================= */

.drawer {
  position: fixed; inset: 0; z-index: 110;
  pointer-events: none; /* disabled until open */
}
.drawer[aria-hidden="true"] { display: block; } /* keep in DOM for transitions */

.drawer-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity .24s ease;
}

.drawer-panel {
  position: absolute; top: 0; left: 0;
  height: 100%; width: min(480px, 92vw);
  background: var(--drawer-panel);
  color: var(--text);
  box-shadow: var(--drawer-shadow);
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.drawer.open { pointer-events: auto; }
.drawer.open .drawer-overlay { opacity: 1; }
.drawer.open .drawer-panel { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(255,255,255,.04), transparent);
}
.drawer-title {
  font-size: 1.1rem; font-weight: 700; letter-spacing: .01em;
}
.drawer-close {
  background: none; border: none; color: var(--text);
  font-size: 1.6rem; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.drawer-close:hover { background: rgba(255,255,255,0.06); }

.drawer-body {
  padding: 16px 14px 24px 14px; overflow-y: auto; flex: 1;
}

/* iOS-style “grouped” sections with emoji headers */
.section {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  margin-bottom: 14px;
  overflow: hidden;
}
.section-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  font-weight: 700;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.section-header .emoji { font-size: 1.2rem; }
.section-body { padding: 10px 14px 6px; }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; }
.kv + .kv { border-top: 1px solid rgba(255,255,255,0.06); }

/* Small charts inside drawer */
.drawer-body canvas {
  max-height: 180px;
  background: rgba(0,0,0,0.12);
  border-radius: 10px;
  padding: 8px;
  margin-top: 8px;
}
