/**
 * 🍎 Apple风格错误处理和用户引导样式
 */

/* =============== 错误页面样式 =============== */

.apple-error-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--apple-background-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--apple-duration-medium) var(--apple-easing-standard);
}

.apple-error-page--visible {
    opacity: 1;
    visibility: visible;
}

.apple-error-page__content {
    text-align: center;
    max-width: 480px;
    padding: 40px 24px;
    animation: apple-error-fade-in var(--apple-duration-medium) var(--apple-easing-decelerate);
}

.apple-error-page__icon {
    margin-bottom: 24px;
    color: var(--apple-error);
    opacity: 0.8;
}

.apple-error-page__title {
    font-family: var(--apple-font-system);
    font-size: 28px;
    font-weight: 700;
    color: var(--apple-label-primary);
    margin-bottom: 16px;
    line-height: 1.2;
}

.apple-error-page__message {
    font-family: var(--apple-font-system);
    font-size: 17px;
    color: var(--apple-label-secondary);
    margin-bottom: 32px;
    line-height: 1.4;
}

.apple-error-page__actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.apple-error-page__action {
    font-family: var(--apple-font-system);
    font-size: 17px;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: var(--apple-radius-medium);
    border: none;
    cursor: pointer;
    transition: all var(--apple-duration-fast) var(--apple-easing-standard);
    min-width: 120px;
}

.apple-error-page__action--primary {
    background: var(--apple-blue);
    color: white;
}

.apple-error-page__action--primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.apple-error-page__action--secondary {
    background: var(--apple-fill-secondary);
    color: var(--apple-label-primary);
}

.apple-error-page__action--secondary:hover {
    background: var(--apple-fill-tertiary);
    transform: translateY(-1px);
}

@keyframes apple-error-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============== 聚光灯引导样式 =============== */

.apple-spotlight {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2500;
    opacity: 0;
    visibility: hidden;
    transition: all var(--apple-duration-medium) var(--apple-easing-standard);
    pointer-events: none;
}

.apple-spotlight--visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.apple-spotlight__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    
    /* 创建聚光灯效果 */
    mask: radial-gradient(
        circle var(--spotlight-size, 100px) at var(--target-x, 50%) var(--target-y, 50%),
        transparent 50%,
        black 50%
    );
    -webkit-mask: radial-gradient(
        circle var(--spotlight-size, 100px) at var(--target-x, 50%) var(--target-y, 50%),
        transparent 50%,
        black 50%
    );
}

.apple-spotlight__content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--apple-background-primary);
    border-radius: var(--apple-radius-large);
    box-shadow: var(--apple-shadow-modal);
    padding: 32px;
    max-width: 400px;
    text-align: center;
    animation: apple-spotlight-slide-in var(--apple-duration-medium) var(--apple-easing-spring);
}

.apple-spotlight__title {
    font-family: var(--apple-font-system);
    font-size: 22px;
    font-weight: 700;
    color: var(--apple-label-primary);
    margin-bottom: 12px;
    line-height: 1.3;
}

.apple-spotlight__description {
    font-family: var(--apple-font-system);
    font-size: 16px;
    color: var(--apple-label-secondary);
    margin-bottom: 24px;
    line-height: 1.4;
}

.apple-spotlight__actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.apple-spotlight__action,
.apple-spotlight__next {
    font-family: var(--apple-font-system);
    font-size: 16px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--apple-radius-small);
    border: none;
    cursor: pointer;
    transition: all var(--apple-duration-fast) var(--apple-easing-standard);
}

.apple-spotlight__next {
    background: var(--apple-blue);
    color: white;
}

.apple-spotlight__next:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.apple-spotlight__action {
    background: var(--apple-fill-secondary);
    color: var(--apple-label-primary);
}

.apple-spotlight__action:hover {
    background: var(--apple-fill-tertiary);
}

@keyframes apple-spotlight-slide-in {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* =============== 工具提示样式 =============== */

.apple-guide-tooltip {
    position: fixed;
    z-index: 2100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--apple-duration-medium) var(--apple-easing-decelerate);
    pointer-events: none;
}

.apple-guide-tooltip--visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.apple-guide-tooltip__content {
    background: var(--apple-background-primary);
    border: 1px solid var(--apple-separator);
    border-radius: var(--apple-radius-medium);
    box-shadow: var(--apple-shadow-heavy);
    padding: 16px 20px;
    max-width: 280px;
    backdrop-filter: var(--apple-blur-light);
    -webkit-backdrop-filter: var(--apple-blur-light);
}

.apple-guide-tooltip__title {
    font-family: var(--apple-font-system);
    font-size: 16px;
    font-weight: 600;
    color: var(--apple-label-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}

.apple-guide-tooltip__description {
    font-family: var(--apple-font-system);
    font-size: 14px;
    color: var(--apple-label-secondary);
    margin-bottom: 16px;
    line-height: 1.4;
}

.apple-guide-tooltip__actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.apple-guide-tooltip__skip,
.apple-guide-tooltip__next {
    font-family: var(--apple-font-system);
    font-size: 14px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--apple-radius-small);
    border: none;
    cursor: pointer;
    transition: all var(--apple-duration-fast) var(--apple-easing-standard);
}

.apple-guide-tooltip__skip {
    background: transparent;
    color: var(--apple-label-tertiary);
}

.apple-guide-tooltip__skip:hover {
    color: var(--apple-label-secondary);
    background: var(--apple-fill-quaternary);
}

.apple-guide-tooltip__next {
    background: var(--apple-blue);
    color: white;
}

.apple-guide-tooltip__next:hover {
    background: #0056b3;
}

.apple-guide-tooltip__arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

/* 箭头方向变体 */
.apple-guide-tooltip--bottom .apple-guide-tooltip__arrow {
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 8px 8px 8px;
    border-color: transparent transparent var(--apple-background-primary) transparent;
}

.apple-guide-tooltip--top .apple-guide-tooltip__arrow {
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 8px 0 8px;
    border-color: var(--apple-background-primary) transparent transparent transparent;
}

.apple-guide-tooltip--left .apple-guide-tooltip__arrow {
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 8px 0 8px 8px;
    border-color: transparent transparent transparent var(--apple-background-primary);
}

.apple-guide-tooltip--right .apple-guide-tooltip__arrow {
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 8px 8px 8px 0;
    border-color: transparent var(--apple-background-primary) transparent transparent;
}

/* =============== 引导覆盖层样式 =============== */

.apple-guide-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2200;
    opacity: 0;
    visibility: hidden;
    transition: all var(--apple-duration-medium) var(--apple-easing-standard);
}

.apple-guide-overlay--visible {
    opacity: 1;
    visibility: visible;
}

.apple-guide-overlay__content {
    background: var(--apple-background-primary);
    border-radius: var(--apple-radius-large);
    box-shadow: var(--apple-shadow-modal);
    padding: 48px 32px 32px;
    max-width: 480px;
    text-align: center;
    animation: apple-overlay-zoom-in var(--apple-duration-medium) var(--apple-easing-spring);
}

.apple-guide-overlay__icon {
    margin-bottom: 24px;
    color: var(--apple-blue);
}

.apple-guide-overlay__title {
    font-family: var(--apple-font-system);
    font-size: 28px;
    font-weight: 700;
    color: var(--apple-label-primary);
    margin-bottom: 16px;
    line-height: 1.2;
}

.apple-guide-overlay__description {
    font-family: var(--apple-font-system);
    font-size: 17px;
    color: var(--apple-label-secondary);
    margin-bottom: 32px;
    line-height: 1.4;
}

.apple-guide-overlay__actions {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.apple-guide-overlay__primary,
.apple-guide-overlay__secondary {
    font-family: var(--apple-font-system);
    font-size: 17px;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: var(--apple-radius-medium);
    border: none;
    cursor: pointer;
    transition: all var(--apple-duration-fast) var(--apple-easing-standard);
    min-width: 120px;
}

.apple-guide-overlay__primary {
    background: var(--apple-blue);
    color: white;
}

.apple-guide-overlay__primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.apple-guide-overlay__secondary {
    background: var(--apple-fill-secondary);
    color: var(--apple-label-primary);
}

.apple-guide-overlay__secondary:hover {
    background: var(--apple-fill-tertiary);
}

@keyframes apple-overlay-zoom-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* =============== 引导模态框样式 =============== */

.apple-guide-modal {
    padding: 24px 0;
    text-align: center;
}

.apple-guide-modal__icon {
    margin-bottom: 20px;
    color: var(--apple-blue);
}

.apple-guide-modal__description {
    font-family: var(--apple-font-system);
    font-size: 16px;
    color: var(--apple-label-primary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.apple-guide-modal__image {
    margin: 24px 0;
}

.apple-guide-modal__image img {
    max-width: 100%;
    height: auto;
    border-radius: var(--apple-radius-medium);
    box-shadow: var(--apple-shadow-light);
}

.apple-guide-modal__actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* =============== 上下文帮助样式 =============== */

.apple-contextual-help {
    padding: 8px 0;
}

.apple-help-content h3 {
    font-family: var(--apple-font-system);
    font-size: 18px;
    font-weight: 600;
    color: var(--apple-label-primary);
    margin-bottom: 16px;
}

.apple-help-content ol,
.apple-help-content ul {
    padding-left: 20px;
    margin-bottom: 16px;
}

.apple-help-content li {
    font-family: var(--apple-font-system);
    font-size: 15px;
    color: var(--apple-label-primary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.apple-help-tip {
    background: var(--apple-background-secondary);
    border-left: 4px solid var(--apple-blue);
    padding: 12px 16px;
    border-radius: 0 var(--apple-radius-small) var(--apple-radius-small) 0;
    margin-top: 20px;
}

.apple-help-tip strong {
    color: var(--apple-blue);
}

.apple-contextual-help__actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--apple-separator);
}

/* =============== 通用按钮样式 =============== */

.apple-btn {
    font-family: var(--apple-font-system);
    font-size: 16px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--apple-radius-small);
    border: none;
    cursor: pointer;
    transition: all var(--apple-duration-fast) var(--apple-easing-standard);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    touch-action: manipulation;
}

.apple-btn--primary {
    background: var(--apple-blue);
    color: white;
}

.apple-btn--primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.apple-btn--secondary {
    background: var(--apple-fill-secondary);
    color: var(--apple-label-primary);
}

.apple-btn--secondary:hover {
    background: var(--apple-fill-tertiary);
}

.apple-btn:active {
    transform: translateY(0);
}

/* =============== 响应式设计 =============== */

@media (max-width: 768px) {
    .apple-error-page__content {
        padding: 32px 20px;
    }
    
    .apple-error-page__title {
        font-size: 24px;
    }
    
    .apple-error-page__message {
        font-size: 16px;
    }
    
    .apple-error-page__actions {
        flex-direction: column;
        align-items: center;
    }
    
    .apple-error-page__action {
        width: 100%;
        max-width: 280px;
    }
    
    .apple-spotlight__content {
        margin: 20px;
        padding: 24px;
        max-width: calc(100vw - 40px);
    }
    
    .apple-guide-overlay__content {
        margin: 20px;
        padding: 32px 24px 24px;
        max-width: calc(100vw - 40px);
    }
    
    .apple-guide-overlay__title {
        font-size: 24px;
    }
    
    .apple-guide-overlay__description {
        font-size: 16px;
    }
    
    .apple-guide-overlay__actions {
        flex-direction: column;
        align-items: center;
    }
    
    .apple-guide-overlay__primary,
    .apple-guide-overlay__secondary {
        width: 100%;
        max-width: 240px;
    }
    
    .apple-guide-tooltip__content {
        max-width: calc(100vw - 40px);
        margin: 0 20px;
    }
}

@media (max-width: 480px) {
    .apple-error-page__content {
        padding: 24px 16px;
    }
    
    .apple-error-page__title {
        font-size: 22px;
    }
    
    .apple-spotlight__content {
        margin: 16px;
        padding: 20px;
    }
    
    .apple-spotlight__title {
        font-size: 20px;
    }
    
    .apple-guide-overlay__content {
        margin: 16px;
        padding: 24px 20px 20px;
    }
    
    .apple-guide-overlay__title {
        font-size: 22px;
    }
}

/* =============== 高对比度模式支持 =============== */

@media (prefers-contrast: high) {
    .apple-error-page,
    .apple-spotlight__content,
    .apple-guide-overlay__content,
    .apple-guide-tooltip__content {
        border: 2px solid var(--apple-label-primary);
    }
    
    .apple-btn,
    .apple-error-page__action,
    .apple-spotlight__action,
    .apple-spotlight__next,
    .apple-guide-tooltip__next,
    .apple-guide-overlay__primary {
        border: 2px solid currentColor;
    }
}

/* =============== 减少动画支持 =============== */

@media (prefers-reduced-motion: reduce) {
    .apple-error-page__content,
    .apple-spotlight__content,
    .apple-guide-overlay__content {
        animation: none !important;
    }
    
    .apple-guide-tooltip {
        transform: none !important;
        transition: opacity var(--apple-duration-fast) ease !important;
    }
    
    .apple-btn:hover,
    .apple-error-page__action:hover,
    .apple-spotlight__next:hover {
        transform: none !important;
    }
}

/* =============== 触摸设备优化 =============== */

@media (hover: none) and (pointer: coarse) {
    .apple-btn:hover,
    .apple-error-page__action:hover,
    .apple-spotlight__action:hover,
    .apple-spotlight__next:hover,
    .apple-guide-tooltip__skip:hover,
    .apple-guide-tooltip__next:hover,
    .apple-guide-overlay__primary:hover,
    .apple-guide-overlay__secondary:hover {
        transform: none !important;
    }
    
    /* 增加触摸目标大小 */
    .apple-btn,
    .apple-error-page__action,
    .apple-spotlight__action,
    .apple-spotlight__next,
    .apple-guide-tooltip__skip,
    .apple-guide-tooltip__next,
    .apple-guide-overlay__primary,
    .apple-guide-overlay__secondary {
        min-height: 44px;
        -webkit-tap-highlight-color: rgba(0, 122, 255, 0.1);
    }
}

/* =============== 打印样式 =============== */

@media print {
    .apple-error-page,
    .apple-spotlight,
    .apple-guide-overlay,
    .apple-guide-tooltip {
        display: none !important;
    }
}