/* ============================================
   DVCGate — Premium Design System
   Dark glass · Animated · Responsive
   ============================================ */

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

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

/* ===== TOKENS ===== */
:root {
  /* primary palette */
  --p: #6366f1;          /* indigo-500 */
  --p-light: #818cf8;    /* indigo-400 */
  --p-dark: #4f46e5;     /* indigo-600 */
  --p-glow: rgba(99,102,241,.35);
  --accent: #a78bfa;     /* violet-400 */

  /* semantic */
  --green: #22c55e;
  --green-soft: rgba(34,197,94,.12);
  --red: #ef4444;
  --red-soft: rgba(239,68,68,.12);
  --amber: #f59e0b;
  --amber-soft: rgba(245,158,11,.12);
  --sky: #38bdf8;

  /* surfaces */
  --bg-body: #0f172a;
  --bg-surface: rgba(30,41,59,.65);
  --bg-card: rgba(30,41,59,.55);
  --bg-card-hover: rgba(30,41,59,.75);
  --bg-input: rgba(15,23,42,.5);
  --bg-glass: rgba(255,255,255,.04);
  --border: rgba(148,163,184,.15);
  --border-focus: var(--p);

  /* text */
  --t1: #f1f5f9;    /* slate-100 */
  --t2: #94a3b8;    /* slate-400 */
  --t3: #64748b;    /* slate-500 */
  --t4: #475569;    /* slate-600 */

  /* misc */
  --glass-blur: blur(20px);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-card: 0 8px 32px rgba(0,0,0,.25), 0 0 0 1px var(--border);
  --shadow-glow: 0 0 40px var(--p-glow);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(.4,0,.2,1);
}

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

body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--t1);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

/* Animated gradient blobs behind content */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .4;
  z-index: 0;
  pointer-events: none;
}
body::before {
  width: 600px; height: 600px;
  background: var(--p);
  top: -200px; left: -100px;
  animation: blobFloat 18s ease-in-out infinite alternate;
}
body::after {
  width: 500px; height: 500px;
  background: #7c3aed;
  bottom: -200px; right: -100px;
  animation: blobFloat 22s ease-in-out infinite alternate-reverse;
}

@keyframes blobFloat {
  0%   { transform: translate(0,0) scale(1); }
  50%  { transform: translate(60px,40px) scale(1.15); }
  100% { transform: translate(-30px,80px) scale(1.05); }
}

body > * { position: relative; z-index: 1; }

h1,h2,h3,h4 { font-weight:700; line-height:1.25; }

a { color: var(--p-light); text-decoration:none; transition: color .2s var(--ease); }
a:hover { color: var(--accent); }

/* ============================================
   AUTH PAGES  (Login / Register / Code)
   ============================================ */
.auth-card {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  padding: 44px 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 440px;
  animation: cardIn .5s var(--ease);
}

.auth-card .brand {
  text-align: center;
  margin-bottom: 8px;
}

.auth-card .brand svg { color: var(--p-light); }

.auth-card h1 {
  text-align: center;
  font-size: 1.65rem;
  color: var(--t1);
  margin-bottom: 6px;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--t2);
  font-size: .9rem;
  margin-bottom: 32px;
}

@keyframes cardIn {
  from { opacity:0; transform:translateY(20px) scale(.98); }
  to   { opacity:1; transform:translateY(0) scale(1); }
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.input-group {
  position: relative;
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--t2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.input-group .icon {
  position: absolute;
  left: 14px;
  bottom: 13px;
  color: var(--t3);
  pointer-events: none;
  transition: color .2s var(--ease);
}

input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  padding-left: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--t1);
  font-size: .93rem;
  font-family: var(--font);
  transition: all .2s var(--ease);
  outline: none;
}

.input-group .icon ~ input,
.input-group .icon ~ select {
  padding-left: 42px;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 3px var(--p-glow);
  background: rgba(15,23,42,.7);
}

input::placeholder { color: var(--t4); }
input[readonly] {
  background: var(--bg-glass);
  color: var(--t2);
  border-style: dashed;
  cursor: default;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

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

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all .2s var(--ease);
  letter-spacing: .01em;
  line-height: 1.4;
  position: relative;
  overflow: hidden;
}

.btn:active { transform:scale(.97); }

/* Primary */
.btn-primary {
  background: linear-gradient(135deg, var(--p) 0%, #7c3aed 100%);
  color: white;
  box-shadow: 0 4px 14px var(--p-glow);
}
.btn-primary:hover {
  box-shadow: 0 8px 30px var(--p-glow);
  transform: translateY(-2px);
}

/* Auth primary (full width) */
.auth-card .btn-primary {
  width: 100%;
  padding: 14px;
  font-size: .95rem;
  margin-top: 6px;
}

/* Ghost / secondary */
.btn-ghost {
  background: var(--bg-glass);
  color: var(--t1);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover {
  background: rgba(255,255,255,.08);
  border-color: var(--t3);
}

/* Danger */
.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(239,68,68,.2);
}
.btn-danger:hover {
  background: rgba(239,68,68,.2);
}

/* Small chips */
.btn-chip {
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  font-size: .78rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .2s var(--ease);
  line-height: 1.3;
}
.btn-chip:hover { filter:brightness(1.15); transform:translateY(-1px); }

.btn-chip.indigo  { background:rgba(99,102,241,.15);  color:var(--p-light); }
.btn-chip.green   { background:var(--green-soft);      color:var(--green); }
.btn-chip.amber   { background:var(--amber-soft);      color:var(--amber); }
.btn-chip.red     { background:var(--red-soft);         color:var(--red); }
.btn-chip.violet  { background:rgba(139,92,246,.15);   color:var(--accent); }
.btn-chip.sky     { background:rgba(56,189,248,.12);   color:var(--sky); }

/* ============================================
   MESSAGES / TOASTS
   ============================================ */
.msg {
  text-align: center;
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  display: none;
  font-weight: 500;
  font-size: .87rem;
  animation: fadeUp .3s var(--ease);
}
@keyframes fadeUp {
  from { opacity:0; transform:translateY(-6px); }
  to   { opacity:1; transform:translateY(0); }
}
.msg.success { display:block; background:var(--green-soft); color:var(--green); border:1px solid rgba(34,197,94,.2); }
.msg.error   { display:block; background:var(--red-soft);   color:var(--red);   border:1px solid rgba(239,68,68,.2); }
.msg.info    { display:block; background:rgba(56,189,248,.1); color:var(--sky); border:1px solid rgba(56,189,248,.2); }

/* ============================================
   AUTH FOOTER LINK
   ============================================ */
.auth-footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: .88rem;
  color: var(--t2);
}
.auth-footer a { font-weight:600; }

/* ============================================
   PAGE CONTAINER (Create / Invite sub-pages)
   ============================================ */
.page-wrap {
  max-width: 540px;
  width: 100%;
  animation: cardIn .45s var(--ease);
}

.page-wrap .page-header {
  text-align: center;
  margin-bottom: 28px;
}

.page-wrap .page-header h1 {
  font-size: 1.6rem;
  color: var(--t1);
}

.page-wrap .page-header p {
  color: var(--t2);
  font-size: .9rem;
  margin-top: 6px;
}

.card {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow-card);
}

.card .form-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.card .form-actions .btn { flex:1; }

/* ============================================
   DASHBOARD
   ============================================ */
body:has(.dash) {
  align-items: flex-start;
  padding: 28px clamp(16px,3vw,40px);
}

.dash {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  animation: cardIn .4s var(--ease);
}

/* Top bar */
.dash-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.dash-topbar .logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dash-topbar .logo svg { color: var(--p-light); }

.dash-topbar .logo h1 {
  font-size: 1.55rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--p-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dash-topbar .user-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-area .user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 6px 18px 6px 8px;
}

.user-pill .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--p), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  color: white;
  flex-shrink: 0;
}

.user-pill span {
  font-size: .88rem;
  color: var(--t2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.btn-logout {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--t2);
  padding: 8px 18px;
  border-radius: 40px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s var(--ease);
}
.btn-logout:hover { background:rgba(239,68,68,.1); color:var(--red); border-color:rgba(239,68,68,.3); }

/* Action Bar */
.dash-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

/* Section heading */
.dash-section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--t2);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Grid */
.objects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

/* Object Card */
.obj-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  transition: all .25s var(--ease);
  position: relative;
}

.obj-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(148,163,184,.25);
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow), var(--shadow-card);
}

.obj-card .card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.obj-card .card-head h3 {
  font-size: 1.15rem;
  color: var(--t1);
  word-break: break-word;
  padding-right: 8px;
}

.btn-card-delete {
  background: transparent;
  border: none;
  color: var(--t3);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: all .2s var(--ease);
  flex-shrink: 0;
}
.btn-card-delete:hover { color:var(--red); background:var(--red-soft); }

.obj-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.obj-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .83rem;
}

.obj-meta-row .label {
  color: var(--t3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: .72rem;
}

.obj-meta-row .value {
  color: var(--t2);
  font-weight: 500;
  font-family: 'SF Mono', 'Cascadia Code', monospace, var(--font);
  font-size: .82rem;
}

.obj-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
}

.empty-state .icon-wrap {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--bg-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--t3);
}

.empty-state h3 {
  color: var(--t1);
  font-size: 1.15rem;
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--t3);
  font-size: .9rem;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.modal-overlay.show { display:flex; }

.modal-box {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.4);
  animation: modalIn .25s var(--ease);
}

@keyframes modalIn {
  from { opacity:0; transform:scale(.96) translateY(8px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}

.modal-box .modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-box .modal-head h2 {
  font-size: 1.25rem;
  color: var(--t1);
}

.modal-close {
  background: none;
  border: none;
  color: var(--t3);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  transition: all .2s var(--ease);
}
.modal-close:hover { color:var(--t1); background:rgba(255,255,255,.06); }

.modal-box .modal-title {
  font-size: 1.25rem;
  color: var(--t1);
  margin-bottom: 24px;
}

.modal-box .form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-box .form-actions .btn { flex:1; }

/* ============================================
   USERS LIST (in modal)
   ============================================ */
.users-list { max-height:400px; overflow-y:auto; }

.user-item {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 10px;
  position: relative;
  transition: border-color .2s var(--ease);
}

.user-item:hover { border-color: var(--p); }

.user-item h4 { color:var(--t1); font-size:.95rem; margin-bottom:8px; }

.user-detail {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: .82rem;
}
.user-detail .label { color:var(--t3); font-weight:600; }
.user-detail .value { color:var(--p-light); }

.badge-owner {
  display: inline-block;
  background: linear-gradient(135deg, var(--p), var(--accent));
  color: white;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: .68rem;
  font-weight: 700;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.empty-users { text-align:center; padding:40px 20px; color:var(--t3); }

.btn-remove-user {
  position: absolute;
  top: 12px; right: 12px;
  background: transparent;
  border: none;
  color: var(--t4);
  width: 28px; height: 28px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all .2s var(--ease);
}
.btn-remove-user:hover { background:var(--red-soft); color:var(--red); }

/* ============================================
   SCHEDULE PAGE
   ============================================ */
body:has(.sched) {
  background: var(--bg-body);
  align-items: flex-start;
  padding: 0;
}

.sched {
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding: 40px clamp(16px,3vw,40px);
  animation: cardIn .4s var(--ease);
}

.sched-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 12px;
}

.sched-topbar h1 {
  font-size: 1.55rem;
  color: var(--t1);
}

.sched-topbar .back-link {
  font-weight: 600;
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sched-section {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.sched-section .section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.sched-section .section-head h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--t1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sched-list { display:flex; flex-direction:column; gap:8px; }

.sched-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--p);
  transition: all .2s var(--ease);
}
.sched-item:hover { background:rgba(255,255,255,.06); }
.sched-item.disabled { opacity:.4; border-left-color:var(--t4); }
.sched-item.action-open  { border-left-color:var(--green); }
.sched-item.action-close { border-left-color:var(--red); }

.sched-item .info { flex:1; min-width:0; }
.sched-item .time { font-weight:700; font-size:.95rem; color:var(--t1); margin-bottom:2px; }
.sched-item .details { font-size:.82rem; color:var(--t3); }

.sched-item .actions { display:flex; gap:4px; flex-shrink:0; }

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-xs);
  color: var(--t3);
  transition: all .2s var(--ease);
}
.btn-icon:hover { background:rgba(255,255,255,.06); color:var(--t1); }
.btn-icon.delete:hover { background:var(--red-soft); color:var(--red); }

.btn-add {
  background: linear-gradient(135deg, var(--p) 0%, #7c3aed 100%);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: .82rem;
  transition: all .2s var(--ease);
  white-space: nowrap;
}
.btn-add:hover { box-shadow:0 4px 14px var(--p-glow); transform:translateY(-1px); }

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-group input[type="checkbox"] {
  width: 18px; height: 18px;
  margin: 0;
  accent-color: var(--p);
}
.checkbox-group label { margin:0!important; cursor:pointer; }

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width:5px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--t4); border-radius:10px; }
::-webkit-scrollbar-thumb:hover { background:var(--t3); }

/* ============================================
   UTILITY
   ============================================ */
.form-hint { display:block; color:var(--t3); font-size:.78rem; margin-top:6px; }

@keyframes spin {
  from { transform:rotate(0deg); }
  to   { transform:rotate(360deg); }
}

.loading {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--p);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  html { font-size:15px; }
  body { padding:12px; }

  .auth-card { padding:32px 24px; }
  .auth-card h1 { font-size:1.4rem; }

  .dash-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .dash-topbar .logo h1 { font-size:1.3rem; }

  .dash-topbar .user-area {
    justify-content: space-between;
  }

  .objects-grid { grid-template-columns:1fr; }

  .dash-actions { flex-direction:column; }
  .dash-actions .btn { width:100%; }

  .obj-actions { flex-wrap:wrap; }
  .btn-chip { font-size:.72rem; padding:6px 10px; }

  .page-wrap { width:100%; }
  .card { padding:24px 20px; }
  .card .form-actions { flex-direction:column; }

  .sched-topbar { flex-direction:column; align-items:flex-start; }
  .sched-section { padding:16px; }
  .sched-section .section-head { flex-direction:column; align-items:flex-start; }

  .sched-item { flex-direction:column; align-items:flex-start; gap:10px; }
  .sched-item .actions { width:100%; justify-content:flex-end; }

  .modal-box { padding:24px 20px; }
}

@media (max-width: 480px) {
  .objects-grid { gap:12px; }
  .obj-card { padding:18px; }
  .user-pill span { max-width:100px; }
}
