/* ===================================================
   STM32 语音助手控制台 — Global Styles
   Microsoft Azure Portal Layout
   =================================================== */

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

html, body {
  width: 100%; height: 100%;
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-size: var(--font-size-md);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

[v-cloak] { display: none !important; }
#app { width: 100%; height: 100%; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-tertiary); }

/* ===================================================
   TOP HEADER BAR
   =================================================== */
.az-header {
  height: var(--header-height);
  background: var(--header-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 100;
}

.az-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.az-header__hamburger {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: #fff;
  transition: background .15s;
}
.az-header__hamburger:hover { background: rgba(255,255,255,.15); }
.az-header__hamburger svg { width: 16px; height: 16px; fill: currentColor; }

.az-header__brand {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -.2px;
  user-select: none;
}

.az-header__right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.az-header__status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: calc(var(--font-size-sm) + 1px);
  color: #ffffff;
  font-weight: 600;
  letter-spacing: .2px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: background .2s, color .2s;
}
.az-header__status--ok { color: #ffffff; background: rgba(255,255,255,.12); }
.az-header__status--err { color: #ffffff; background: none; }
.az-header__status--loading { color: #ffffff; background: rgba(255,255,255,.08); }

.az-header__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.az-header__dot--ok {
  background: #92c353;
  animation: az-breathing-light 2s ease-in-out infinite;
}
.az-header__dot--err {
  background: var(--color-text-tertiary);
  animation: az-breathing-light 2s ease-in-out infinite;
}
.az-header__dot--loading {
  background: rgba(255,255,255,.5);
  animation: az-pulse 1.5s ease-in-out infinite;
}

@keyframes az-breathing-light { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes az-pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ===================================================
   APP BODY
   =================================================== */
.az-body {
  display: flex;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* ===================================================
   SIDEBAR
   =================================================== */
.az-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .25s cubic-bezier(.4,0,.2,1), min-width .25s cubic-bezier(.4,0,.2,1);
  flex-shrink: 0;
}

.az-sidebar--collapsed { width: 48px; min-width: 48px; }

.az-sidebar__section { padding: 14px 0 6px 0; }

.az-sidebar__section-title {
  padding: 0 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--sidebar-section-color);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
}

.az-sidebar--collapsed .az-sidebar__section-title { opacity: 0; height: 0; padding: 0; margin: 0; }

.az-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 36px;
  cursor: pointer;
  color: var(--sidebar-item-color);
  font-size: var(--font-size-sm);
  font-weight: 400;
  border-left: 3px solid transparent;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}

.az-nav-item:hover { background: var(--sidebar-hover); }

.az-nav-item--active {
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-bar);
  font-weight: 600;
  color: var(--azure-blue);
}

.az-nav-item__icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.az-nav-item__icon svg { width: 16px; height: 16px; fill: currentColor; }

.az-nav-item__label { overflow: hidden; text-overflow: ellipsis; }

.az-sidebar--collapsed .az-nav-item__label { display: none; }
.az-sidebar--collapsed .az-nav-item { padding: 0; justify-content: center; }

/* ===================================================
   MAIN CONTENT AREA
   =================================================== */
.az-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

/* ---- Toolbar / Breadcrumb ---- */
.az-toolbar {
  height: 44px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.az-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.az-breadcrumb__home {
  color: var(--azure-blue);
  cursor: pointer;
  font-weight: 500;
}
.az-breadcrumb__home:hover { text-decoration: underline; }

.az-breadcrumb__sep { color: var(--color-text-tertiary); font-size: 10px; }
.az-breadcrumb__current { color: var(--color-text-primary); font-weight: 600; }

.az-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Page scroll area ---- */
.az-page {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ---- Page title ---- */
.az-page-title {
  font-size: var(--font-size-xxl);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.az-page-title__icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}
.az-page-title__icon svg { width: 24px; height: 24px; fill: var(--azure-blue); }

/* ===================================================
   FLUENT CARD
   =================================================== */
.az-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-4);
  margin-bottom: 16px;
  transition: box-shadow .2s;
}
.az-card:hover { box-shadow: var(--shadow-8); }

.az-card__header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.az-card__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
}

.az-card__body { padding: 20px; }
.az-card__body--flush { padding: 0; }

/* ===================================================
   METRIC TILES
   =================================================== */
.az-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.az-metric {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-4);
  transition: box-shadow .2s, border-color .2s;
}
.az-metric:hover { box-shadow: var(--shadow-8); border-color: var(--color-border-strong); }

.az-metric__label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.az-metric__value {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-text-primary);
  font-family: var(--font-family-mono);
}
.az-metric__value--success { color: var(--color-success); }
.az-metric__value--danger { color: var(--color-danger); }

.az-metric__sub {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

/* ===================================================
   STATUS BANNER
   =================================================== */
.az-status-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-bottom: 16px;
  border: 1px solid;
  animation: az-fadeSlideIn .3s ease;
}
.az-status-banner--ok { background: var(--color-success-bg); border-color: #a7e3a5; color: #0b5a08; }
.az-status-banner--err { background: var(--color-danger-bg); border-color: #f0aaaa; color: #943030; }

.az-status-banner__icon { width: 20px; height: 20px; flex-shrink: 0; }
.az-status-banner__icon svg { width: 20px; height: 20px; }

.az-status-banner__text { flex: 1; }
.az-status-banner__title { font-weight: 600; font-size: var(--font-size-lg); }
.az-status-banner__desc { font-size: 11px; margin-top: 3px; opacity: .8; }

/* ===================================================
   FORM STYLES
   =================================================== */
.az-form { max-width: 780px; }
.az-form .el-form-item { margin-bottom: 20px; }

.az-form .el-form-item__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  font-weight: 600;
}

.az-form .el-input__wrapper,
.az-form .el-textarea__inner {
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  transition: border-color .15s;
}
.az-form .el-input__wrapper:hover,
.az-form .el-textarea__inner:hover { border-color: var(--color-text-tertiary); }
.az-form .el-input__wrapper.is-focus,
.az-form .el-textarea__inner:focus { border-color: var(--azure-blue) !important; border-width: 2px; }

.az-form .el-input__inner,
.az-form .el-textarea__inner { color: var(--color-text-primary); font-size: var(--font-size-md); }

.az-form .el-select .el-input__wrapper { border-radius: var(--radius-sm) !important; }

/* ---- Switch ---- */
.el-switch { height: 20px; }
.el-switch__core { border-radius: 10px; border: 1px solid var(--color-border-strong); background: var(--color-text-disabled); }
.el-switch.is-checked .el-switch__core { background: var(--azure-blue); border-color: var(--azure-blue); }

/* ---- Helper text ---- */
.az-helper {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-left: 12px;
  line-height: 32px;
  white-space: nowrap;
}

.az-form .el-form-item__content {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
}

/* ===================================================
   BUTTONS
   =================================================== */
.el-button {
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  font-weight: 600;
  padding: 5px 16px;
  height: 32px;
  transition: background .12s, border-color .12s, color .12s;
}

.el-button--primary { background: var(--azure-blue); border-color: var(--azure-blue); color: #fff; }
.el-button--primary:hover { background: var(--azure-blue-hover); border-color: var(--azure-blue-hover); }
.el-button--primary:active { background: var(--azure-blue-active); border-color: var(--azure-blue-active); }

.el-button--default { background: #fff; border: 1px solid var(--color-border-strong); color: var(--color-text-primary); }
.el-button--default:hover { background: var(--color-bg-alt); border-color: var(--color-text-tertiary); color: var(--azure-blue); }

.el-button--danger { background: #fff; border: 1px solid var(--color-danger); color: var(--color-danger); }
.el-button--danger:hover { background: var(--color-danger); color: #fff; }

.el-button.is-loading { opacity: .65; }
.el-button:focus, .el-button:hover { box-shadow: none !important; }

/* ===================================================
   TABLE
   =================================================== */
.el-table { border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.el-table th.el-table__cell { background: var(--color-bg-alt); color: var(--color-text-primary); font-weight: 600; font-size: var(--font-size-sm); }
.el-table td.el-table__cell { font-size: var(--font-size-sm); color: var(--color-text-primary); }
.el-table__body tr:hover > td { background: var(--azure-blue-lighter) !important; }

/* ---- Tag ---- */
.el-tag { border-radius: var(--radius-sm); font-size: var(--font-size-xs); }
.el-tag--primary { background: var(--azure-blue-light); border-color: #a0c8ef; color: var(--azure-blue); }

/* ---- Message ---- */
.el-message { border-radius: var(--radius-sm); font-size: var(--font-size-sm); box-shadow: var(--shadow-8); }

/* ===================================================
   TRANSITIONS
   =================================================== */
.az-fade-enter-active,
.az-fade-leave-active { transition: opacity .2s ease, transform .2s ease; }
.az-fade-enter-from { opacity: 0; transform: translateY(8px); }
.az-fade-leave-to { opacity: 0; transform: translateY(-4px); }

@keyframes az-fadeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===================================================
   SKELETON
   =================================================== */
.az-skeleton { padding: 24px; }

.az-skeleton__block {
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-bg-alt) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: az-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
  height: 14px;
  margin-bottom: 14px;
}

@keyframes az-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===================================================
   LOGIN PAGE
   =================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
}

.login-card {
  width: 380px;
  max-width: 90vw;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-16);
  padding: 40px 32px 32px;
  position: relative;
  overflow: hidden;
}

.login-card__bar {
  height: 4px;
  background: var(--azure-blue);
  position: absolute;
  top: 0; left: 0; right: 0;
}

.login-card__header { text-align: center; margin-bottom: 28px; }
.login-card__logo { display: flex; justify-content: center; margin-bottom: 16px; }

.login-card__title {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.login-card__subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.login-card__form { margin-bottom: 12px; }

/* ===================================================
   HEADER LOGOUT
   =================================================== */
.az-header__logout {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: #fff;
  margin-left: 8px;
  transition: background .15s;
}
.az-header__logout:hover { background: rgba(255,255,255,.15); }
.az-header__logout svg { width: 16px; height: 16px; fill: none; stroke: currentColor; }

/* ===================================================
   CONVERSATION LIST
   =================================================== */
.az-conv-list { list-style: none; padding: 0; }

.az-conv-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background .12s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.az-conv-item:hover { background: var(--color-bg-alt); }
.az-conv-item--active { background: var(--azure-blue-lighter); border-left: 3px solid var(--azure-blue); }

.az-conv-item__title {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
}
.az-conv-item__meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  margin-top: 4px;
}

/* ---- Chat messages ---- */
.az-chat-msg {
  padding: 10px 16px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  max-width: 80%;
  font-size: var(--font-size-sm);
  line-height: 1.6;
  animation: az-fadeSlideIn .2s ease;
}
.az-chat-msg--user {
  background: var(--azure-blue-light);
  color: var(--color-text-primary);
  margin-left: auto;
}
.az-chat-msg--assistant {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}
.az-chat-msg__role {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

/* ===================================================
   MIC TEST & USER SETTINGS
   =================================================== */
.az-section-tip {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: 16px;
}

.test-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-card {
  border: 1px solid var(--color-border);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--azure-blue-light);
  color: var(--azure-blue);
  font-size: var(--font-size-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-title {
  flex: 1;
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text-primary);
}

.step-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.step-result {
  font-size: var(--font-size-sm);
  padding-top: 4px;
}

.text-success { color: var(--color-success); }
.text-error { color: var(--color-danger); }

.step-audio {
  margin: 8px 0;
}

.avatar-upload-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.avatar-uploader {
  width: 92px;
  height: 92px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar-preview,
.avatar-preview img {
  width: 100%;
  height: 100%;
}

.avatar-preview {
  position: relative;
}

.avatar-preview img {
  object-fit: cover;
}

.avatar-hover-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  color: var(--color-text-primary);
  background: var(--header-bg);
  font-size: var(--font-size-xs);
  transition: opacity .15s;
}

.avatar-preview:hover .avatar-hover-overlay {
  opacity: 1;
}

.avatar-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.avatar-placeholder__plus {
  font-size: 24px;
  color: var(--color-text-tertiary);
  line-height: 1;
}

.avatar-placeholder__text,
.form-tip {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.avatar-placeholder__text {
  margin-top: 4px;
}

.form-tip {
  margin-top: 6px;
}

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 768px) {
  .az-sidebar { display: none; }
  .az-page { padding: 16px; }
  .az-toolbar { padding: 0 16px; }
  .az-metrics { grid-template-columns: 1fr; }
}
