/* 全局变量：适配 iOS 刘海与小白条 */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* 全局重置与盒模型 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* 禁用移动端点击高亮 */
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  background-color: #ffffff;
}

body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
  overflow: hidden;
  background-color: #ffffff; /* 修改为纯白 */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* 禁用文本选择，提升原生 App 体验 */
  -webkit-user-select: none;
  user-select: none;
}

#app {
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
}

.app-header {
  /* 适配顶部安全区（刘海屏/状态栏） */
  padding-top: var(--safe-top);
  height: calc(44px + var(--safe-top));
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-bottom: 1px solid #e5e5ea;
  color: #111;
  font-weight: 600;
  font-size: 17px;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  /* 平滑滚动 */
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  color: #333;
  line-height: 1.6;
}

.app-content p {
  margin-bottom: 15px;
  background: #fff;
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.app-tabbar {
  /* 适配底部安全区（小白条） */
  padding-bottom: var(--safe-bottom);
  height: calc(50px + var(--safe-bottom));
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-shrink: 0;
  border-top: 1px solid #e5e5ea;
  color: #8e8e93;
  font-size: 12px;
}

.app-tabbar div {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 50px;
  cursor: pointer;
}

/* ==========================================
   合并自 iiso/ios_emulator.css 的样式
   ========================================== */

/* 重新定义局部变量，覆盖 iiso 的根变量以匹配当前上下文 */
:root {
    --bg-color: #ffffff; /* 修改为纯白 */
    --screen-bg: #ffffff;
    --home-bg-image: none;
    --app-icon-bg-image: none;
    --text-primary: #000000;
    --text-secondary: #8e8e93;
    --bubble-bg: #f2f2f7;
    --icon-gray: #d1d1d6;
    --accent-color: #000000;
    --dock-bg: rgba(255, 255, 255, 0.7);
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-icon: 0 2px 8px rgba(0, 0, 0, 0.08);
    --settings-bg: #f2f2f7;
    --header-blur: rgba(255, 255, 255, 0.75);
    --blue-color: #007aff;
    --separator-color: #c6c6c8;
    --radius-bubble: 20px;
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --z-base: 1;
    --z-nav: 100;
    --z-overlay: 500;
    --z-modal: 1000;
    --z-toast: 9999;
    --z-system: 99999;
}

/* 移除重复的通用样式定义，保留 iiso 专有的组件样式 */

input, textarea, [contenteditable] {
    user-select: text;
    -webkit-user-select: text;
}

/* Toast Bubble Notification */
.toast-bubble {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: rgba(255, 255, 255, 0.95);
    color: #000;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.17, 0.84, 0.44, 1);
    white-space: nowrap;
    text-align: center;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast-bubble.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* iOS Toggle Switch - Global */
.toggle-switch {
    position: relative;
    display: inline-block !important;
    width: 51px !important;
    height: 31px !important;
    min-width: 51px;
    min-height: 31px;
    flex-shrink: 0 !important;
    box-sizing: border-box;
    margin: 0 !important;
    padding: 0 !important;
    flex: none !important;
    align-self: center;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: none !important;
    position: absolute;
    pointer-events: none;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e9e9ea;
    transition: .4s;
    border-radius: 31px;
}

.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .slider {
    background-color: #34c759;
}

.toggle-switch input:focus + .slider {
    box-shadow: 0 0 1px #34c759;
}

.toggle-switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* Global Textarea for Persona, Bios, Descriptions */
.global-textarea {
    width: 100%;
    min-height: 120px;
    background: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 16px;
    font-size: 15px;
    color: #111;
    resize: none;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
}
.global-textarea::placeholder {
    color: #8e8e93;
}
.global-textarea:focus {
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Specific inputs */
.form-item input.small-rounded-input {
    flex: none; 
    border: 1px solid var(--separator-color, #e5e5ea);
    border-radius: 8px;
    padding: 4px;
    font-size: 15px;
    background: transparent;
    color: #111;
}

.form-item input.small-rounded-input:focus {
    border-color: var(--blue-color, #007aff);
}

/* Bottom Sheet Styles */
.bottom-sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.bottom-sheet-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.detail-sheet-overlay {
    z-index: 250;
}

.bottom-sheet {
    background-color: rgba(242, 242, 247, 0.9);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 10px 16px 0; /* 移除写死的底部40px间距，让内容去避让安全区 */
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.17, 0.84, 0.44, 1);
    max-height: 85%;
    display: flex;
    flex-direction: column;
}

.detail-sheet-content {
    overflow-y: auto;
    flex: 1;
    padding-bottom: max(20px, env(safe-area-inset-bottom)); /* 适配全面屏底部安全区 */
}

.bottom-sheet-overlay.active .bottom-sheet {
    transform: translateY(0);
}

.sheet-handle {
    width: 36px;
    height: 5px;
    background-color: #c5c5c7;
    border-radius: 3px;
    margin: 8px auto 20px;
    opacity: 0.8;
}

.sheet-title {
    font-size: 13px;
    font-weight: 600;
    color: #8e8e93;
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sheet-action {
    background-color: #fff;
    padding: 14px;
    border-radius: var(--radius-bubble, 20px);
    text-align: center;
    color: var(--blue-color, #007aff);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}

.sheet-action:active {
    background-color: #e5e5ea;
}

.sheet-action i {
    margin-right: 8px;
    font-size: 18px;
}

.confirm-action {
    margin: 0 16px;
}

/* API Error Popup - iOS Style */
.api-error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.api-error-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.api-error-modal {
    background-color: rgba(250, 250, 250, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    width: 270px;
    max-width: 90%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 20px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(1.1);
    transition: transform 0.25s cubic-bezier(0.17, 0.84, 0.44, 1);
}

.api-error-overlay.show .api-error-modal {
    transform: scale(1);
}

.api-error-content {
    padding: 20px 16px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.api-error-title {
    font-size: 17px;
    font-weight: 600;
    color: #000;
    margin-bottom: 6px;
    text-align: center;
}

.api-error-message {
    font-size: 13px;
    color: #3c3c43;
    text-align: center;
    line-height: 1.3;
    margin-bottom: 14px;
    word-break: break-word;
}

.api-error-raw-wrapper {
    width: 100%;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 8px;
    max-height: 120px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.api-error-raw {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", monospace;
    font-size: 11px;
    color: #1c1c1e;
    word-break: break-all;
    white-space: pre-wrap;
    line-height: 1.4;
    margin: 0;
}

.api-error-button {
    width: 100%;
    padding: 11px;
    background: transparent;
    border: none;
    border-top: 1px solid rgba(60, 60, 67, 0.29);
    color: #007aff;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s;
}

.api-error-button:active {
    background-color: rgba(0, 0, 0, 0.05);
}
