/* ============================================================
   SWS Dashboard — Component Styles
   sws.css 디자인 시스템 위에 대시보드 전용 컴포넌트
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   1. DASHBOARD LAYOUT
   ──────────────────────────────────────────────────────────── */

/* Full-page wrapper */
.sws-dash {
  min-height: 100vh;
  background: var(--sws-bg);
  color: var(--sws-text);
  position: relative;
}

/* ── Top Navigation ── */
.sws-dash__nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--sws-z-fixed);
  height: 64px;
  background: rgba(10, 10, 26, .72);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--sws-border);
  transition: background var(--sws-duration-slow) var(--sws-ease),
              box-shadow var(--sws-duration-slow) var(--sws-ease);
}
.sws-dash__nav.is-scrolled {
  background: rgba(10, 10, 26, .92);
  box-shadow: var(--sws-shadow-md);
}

.sws-dash__nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--sws-container);
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--sws-space-6);
}

/* Logo area */
.sws-dash__nav-logo {
  display: flex;
  align-items: center;
  gap: var(--sws-space-3);
  text-decoration: none;
  flex-shrink: 0;
}
.sws-dash__nav-logo-text {
  font-size: var(--sws-text-xl);
  font-weight: 800;
  background: var(--sws-gradient-h);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: var(--sws-tracking-tight);
}
.sws-dash__nav-logo-label {
  font-size: var(--sws-text-xs);
  font-weight: 600;
  color: var(--sws-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--sws-tracking-wider);
  padding-left: var(--sws-space-2);
  border-left: 1px solid var(--sws-border-light);
}

/* User area (right side of nav) */
.sws-dash__nav-user {
  display: flex;
  align-items: center;
  gap: var(--sws-space-4);
}
.sws-dash__nav-username {
  font-size: var(--sws-text-sm);
  font-weight: 500;
  color: var(--sws-text-secondary);
}
.sws-dash__nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--sws-border-radius-full);
  background: var(--sws-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--sws-text-xs);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* Main content — offset for fixed nav */
.sws-dash__main {
  padding-top: calc(64px + var(--sws-space-10));
  padding-bottom: var(--sws-space-16);
  min-height: calc(100vh - 60px);
}

/* Container */
.sws-dash__container {
  width: 100%;
  max-width: var(--sws-container);
  margin: 0 auto;
  padding: 0 var(--sws-space-6);
}


/* ────────────────────────────────────────────────────────────
   2. WELCOME / STATS
   ──────────────────────────────────────────────────────────── */

.sws-dash__welcome {
  margin-bottom: var(--sws-space-10);
}
.sws-dash__welcome-title {
  font-size: var(--sws-text-3xl);
  font-weight: 800;
  letter-spacing: var(--sws-tracking-tight);
  margin-bottom: var(--sws-space-2);
}
.sws-dash__welcome-sub {
  font-size: var(--sws-text-base);
  color: var(--sws-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sws-space-3);
}

/* Stats row */
.sws-dash__stats {
  display: flex;
  gap: var(--sws-space-6);
  margin-bottom: var(--sws-space-12);
  flex-wrap: wrap;
}

/* Individual stat card */
.sws-dash__stat {
  flex: 1;
  min-width: 180px;
  background: var(--sws-surface-2);
  border: 1px solid var(--sws-border);
  border-radius: var(--sws-border-radius-lg);
  padding: var(--sws-space-6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--sws-duration) var(--sws-ease),
              box-shadow var(--sws-duration) var(--sws-ease);
}
.sws-dash__stat:hover {
  border-color: var(--sws-border-light);
  box-shadow: var(--sws-shadow-glow-sm);
}

.sws-dash__stat-icon {
  font-size: var(--sws-text-2xl);
  margin-bottom: var(--sws-space-3);
}

.sws-dash__stat-value {
  font-size: var(--sws-text-2xl);
  font-weight: 800;
  color: var(--sws-text);
  letter-spacing: var(--sws-tracking-tight);
  line-height: 1;
  margin-bottom: var(--sws-space-1);
}

.sws-dash__stat-label {
  font-size: var(--sws-text-xs);
  color: var(--sws-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--sws-tracking-wide);
}


/* ────────────────────────────────────────────────────────────
   3. BOT CARDS GRID
   ──────────────────────────────────────────────────────────── */

/* Section header row — title + action */
.sws-dash__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sws-space-8);
  flex-wrap: wrap;
  gap: var(--sws-space-4);
}
.sws-dash__section-title {
  font-size: var(--sws-text-xl);
  font-weight: 700;
}

/* Responsive grid */
.sws-dash__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sws-space-6);
}

/* Bot card */
.sws-dash__bot-card {
  background: var(--sws-surface-2);
  border: 1px solid var(--sws-border);
  border-radius: var(--sws-border-radius-lg);
  padding: var(--sws-space-6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: var(--sws-space-5);
  transition: transform var(--sws-duration) var(--sws-ease),
              box-shadow var(--sws-duration) var(--sws-ease),
              border-color var(--sws-duration) var(--sws-ease);
  position: relative;
  overflow: hidden;
}
/* Accent line on top */
.sws-dash__bot-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--sws-gradient);
  opacity: 0;
  transition: opacity var(--sws-duration) var(--sws-ease);
}
.sws-dash__bot-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--sws-shadow-lg), var(--sws-shadow-glow-sm);
  border-color: var(--sws-border-light);
}
.sws-dash__bot-card:hover::before {
  opacity: 1;
}

/* Card header */
.sws-dash__bot-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sws-space-3);
}
.sws-dash__bot-card-name {
  font-size: var(--sws-text-lg);
  font-weight: 700;
  color: var(--sws-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status badge */
.sws-dash__bot-status {
  display: inline-flex;
  align-items: center;
  gap: var(--sws-space-1);
  font-size: var(--sws-text-xs);
  font-weight: 600;
  padding: .2rem .6rem;
  border-radius: var(--sws-border-radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}
.sws-dash__bot-status--active {
  background: var(--sws-success-soft);
  color: var(--sws-success);
  border: 1px solid rgba(0, 200, 81, .25);
}
.sws-dash__bot-status--building {
  background: var(--sws-warning-soft);
  color: var(--sws-warning);
  border: 1px solid rgba(255, 187, 51, .25);
}
.sws-dash__bot-status--paused {
  background: rgba(255, 255, 255, .06);
  color: var(--sws-text-muted);
  border: 1px solid var(--sws-border);
}

/* Card stats */
.sws-dash__bot-card-stats {
  display: flex;
  align-items: center;
  gap: var(--sws-space-6);
  font-size: var(--sws-text-sm);
  color: var(--sws-text-secondary);
}
.sws-dash__bot-card-stat {
  display: flex;
  align-items: center;
  gap: var(--sws-space-2);
}
.sws-dash__bot-card-stat-icon {
  opacity: .6;
}

/* Card meta (id, date) */
.sws-dash__bot-card-meta {
  font-size: var(--sws-text-xs);
  color: var(--sws-text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sws-space-2);
}
.sws-dash__bot-card-id {
  font-family: var(--sws-font-mono);
  font-size: 10px;
  opacity: .5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

/* Card actions */
.sws-dash__bot-card-actions {
  display: flex;
  gap: var(--sws-space-3);
  margin-top: auto;
  padding-top: var(--sws-space-4);
  border-top: 1px solid var(--sws-border);
}


/* ────────────────────────────────────────────────────────────
   4. EMPTY STATE
   ──────────────────────────────────────────────────────────── */

.sws-dash__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sws-space-20) var(--sws-space-6);
  background: var(--sws-surface-1);
  border: 1px dashed var(--sws-border-light);
  border-radius: var(--sws-border-radius-xl);
}
.sws-dash__empty-icon {
  font-size: 4rem;
  margin-bottom: var(--sws-space-6);
  opacity: .7;
  animation: float 4s ease-in-out infinite;
}
.sws-dash__empty-title {
  font-size: var(--sws-text-xl);
  font-weight: 700;
  margin-bottom: var(--sws-space-3);
  color: var(--sws-text);
}
.sws-dash__empty-desc {
  font-size: var(--sws-text-sm);
  color: var(--sws-text-muted);
  max-width: 380px;
  margin-bottom: var(--sws-space-8);
  line-height: var(--sws-leading-relaxed);
}


/* ────────────────────────────────────────────────────────────
   5. FORM COMPONENTS (Dashboard Forms)
   ──────────────────────────────────────────────────────────── */

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

.sws-form__group {
  display: flex;
  flex-direction: column;
  gap: var(--sws-space-2);
}

.sws-form__label {
  font-size: var(--sws-text-sm);
  font-weight: 600;
  color: var(--sws-text-secondary);
}
.sws-form__label--required::after {
  content: ' *';
  color: var(--sws-error);
}

.sws-form__input,
.sws-form__textarea,
.sws-form__select {
  width: 100%;
  font-family: var(--sws-font);
  font-size: var(--sws-text-sm);
  color: var(--sws-text);
  background: var(--sws-surface-1);
  border: 1px solid var(--sws-border);
  border-radius: var(--sws-border-radius);
  padding: .75rem 1rem;
  outline: none;
  transition: border-color var(--sws-duration) var(--sws-ease),
              box-shadow var(--sws-duration) var(--sws-ease),
              background var(--sws-duration) var(--sws-ease);
}
.sws-form__input:hover,
.sws-form__textarea:hover,
.sws-form__select:hover {
  border-color: var(--sws-border-light);
  background: var(--sws-surface-2);
}
.sws-form__input:focus,
.sws-form__textarea:focus,
.sws-form__select:focus {
  border-color: var(--sws-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, .15), var(--sws-shadow-glow-sm);
  background: var(--sws-surface-2);
}
.sws-form__input::placeholder,
.sws-form__textarea::placeholder {
  color: var(--sws-text-muted);
}
.sws-form__textarea {
  resize: vertical;
  min-height: 120px;
  line-height: var(--sws-leading-normal);
}
.sws-form__select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6b8a' d='M6 8.825a.5.5 0 0 1-.354-.146l-3.5-3.5a.5.5 0 0 1 .708-.708L6 7.618l3.146-3.147a.5.5 0 0 1 .708.708l-3.5 3.5A.5.5 0 0 1 6 8.825Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.sws-form__help {
  font-size: var(--sws-text-xs);
  color: var(--sws-text-muted);
  line-height: var(--sws-leading-normal);
}

.sws-form__error {
  font-size: var(--sws-text-xs);
  color: var(--sws-error);
  display: flex;
  align-items: center;
  gap: var(--sws-space-1);
}
.sws-form__error::before {
  content: '⚠';
  font-size: 11px;
}

/* Input error state */
.sws-form__input--error,
.sws-form__textarea--error,
.sws-form__select--error {
  border-color: var(--sws-error);
}
.sws-form__input--error:focus,
.sws-form__textarea--error:focus,
.sws-form__select--error:focus {
  box-shadow: 0 0 0 3px rgba(255, 68, 68, .15);
}


/* ────────────────────────────────────────────────────────────
   6. AUTH PAGE LAYOUT
   ──────────────────────────────────────────────────────────── */

.sws-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sws-space-8);
  background: var(--sws-bg);
  position: relative;
}
/* Ambient glow behind auth card */
.sws-auth::before {
  content: '';
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(102, 126, 234, .10) 0%, transparent 65%);
  pointer-events: none;
}

.sws-auth__card {
  width: 100%;
  max-width: 420px;
  background: var(--sws-surface-2);
  border: 1px solid var(--sws-border);
  border-radius: var(--sws-border-radius-xl);
  padding: var(--sws-space-10);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: relative;
  z-index: 1;
  animation: slideIn .5s var(--sws-ease) both;
}
/* Gradient accent line */
.sws-auth__card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--sws-gradient);
  border-radius: var(--sws-border-radius-xl) var(--sws-border-radius-xl) 0 0;
}

.sws-auth__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sws-space-3);
  margin-bottom: var(--sws-space-8);
  text-decoration: none;
}
.sws-auth__logo-text {
  font-size: var(--sws-text-2xl);
  font-weight: 800;
  background: var(--sws-gradient-h);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sws-auth__title {
  font-size: var(--sws-text-xl);
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--sws-space-2);
}

.sws-auth__subtitle {
  font-size: var(--sws-text-sm);
  color: var(--sws-text-muted);
  text-align: center;
  margin-bottom: var(--sws-space-8);
}

.sws-auth__footer {
  text-align: center;
  margin-top: var(--sws-space-6);
  font-size: var(--sws-text-sm);
  color: var(--sws-text-muted);
}
.sws-auth__footer a {
  color: var(--sws-primary);
  font-weight: 600;
}
.sws-auth__footer a:hover {
  color: var(--sws-accent);
}

.sws-auth__divider {
  display: flex;
  align-items: center;
  gap: var(--sws-space-4);
  margin: var(--sws-space-6) 0;
  color: var(--sws-text-muted);
  font-size: var(--sws-text-xs);
  text-transform: uppercase;
  letter-spacing: var(--sws-tracking-wider);
}
.sws-auth__divider::before,
.sws-auth__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--sws-border);
}


/* ────────────────────────────────────────────────────────────
   7. DASHBOARD FOOTER
   ──────────────────────────────────────────────────────────── */

.sws-dash__footer {
  text-align: center;
  padding: var(--sws-space-8) var(--sws-space-6);
  border-top: 1px solid var(--sws-border);
  margin-top: var(--sws-space-16);
  font-size: var(--sws-text-xs);
  color: var(--sws-text-muted);
}


/* ────────────────────────────────────────────────────────────
   8. UTILITY — Tooltips
   ──────────────────────────────────────────────────────────── */

[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(.92);
  padding: .35rem .65rem;
  background: var(--sws-bg-alt);
  border: 1px solid var(--sws-border-light);
  border-radius: var(--sws-border-radius-sm);
  font-size: var(--sws-text-xs);
  color: var(--sws-text-secondary);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--sws-duration-fast) var(--sws-ease),
              transform var(--sws-duration-fast) var(--sws-ease);
  z-index: var(--sws-z-tooltip);
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}


/* ────────────────────────────────────────────────────────────
   9. RESPONSIVE
   ──────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .sws-dash__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sws-dash__grid {
    grid-template-columns: 1fr;
  }
  .sws-dash__stats {
    flex-direction: column;
  }
  .sws-dash__stat {
    min-width: auto;
  }
  .sws-dash__welcome-title {
    font-size: var(--sws-text-2xl);
  }
  .sws-dash__nav-username {
    display: none;
  }
  .sws-dash__section-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .sws-auth__card {
    padding: var(--sws-space-8) var(--sws-space-6);
  }
}

@media (max-width: 480px) {
  .sws-dash__container {
    padding: 0 var(--sws-space-4);
  }
  .sws-dash__bot-card {
    padding: var(--sws-space-5);
  }
  .sws-dash__bot-card-stats {
    flex-direction: column;
    gap: var(--sws-space-2);
  }
}
