/**
 * iOS 3D Touch / Haptic Touch Preview Styles
 * Peek and pop preview cards
 */

/* Preview Container */
.ios-preview-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 13000; /* Gesture/preview layer - above all UI */
    pointer-events: none;
    /* PWA Safe Area Support */
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
}

.ios-preview-active {
    pointer-events: auto;
}

/* Backdrop */
.ios-preview-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ios-preview-active .ios-preview-backdrop {
    opacity: 1;
}

/* Preview Content Wrapper */
.ios-preview-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Preview Card */
.ios-preview-card {
    position: absolute;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 400px;
    width: calc(100vw - 40px);
}

.ios-preview-active .ios-preview-card {
    transform: scale(1);
    opacity: 1;
}

/* Preview Header */
.ios-preview-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
}

.ios-preview-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #000;
    flex: 1;
}

.ios-preview-subtitle {
    font-size: 13px;
    color: #8E8E93;
    margin: 2px 0 0;
}

/* Preview Avatar */
.ios-preview-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #007AFF;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
}

.ios-preview-header-text {
    flex: 1;
    min-width: 0;
}

.ios-preview-header-text h3 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Preview Badge */
.ios-preview-badge {
    padding: 4px 10px;
    background: rgba(0, 122, 255, 0.15);
    color: #007AFF;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* Preview Body */
.ios-preview-body {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.ios-preview-description {
    font-size: 14px;
    line-height: 1.5;
    color: #000;
    margin: 0 0 12px;
}

/* Preview Field */
.ios-preview-field {
    margin-bottom: 12px;
}

.ios-preview-field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #8E8E93;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.ios-preview-field-value {
    display: block;
    font-size: 15px;
    color: #000;
}

.ios-preview-notes {
    font-size: 14px;
    line-height: 1.5;
    color: #000;
    margin: 4px 0 0;
}

/* Preview Stats */
.ios-preview-stats {
    display: flex;
    gap: 20px;
    margin-top: 16px;
    padding: 12px 0;
    border-top: 0.5px solid rgba(0, 0, 0, 0.1);
}

.ios-preview-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.ios-preview-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #007AFF;
}

.ios-preview-stat-label {
    font-size: 12px;
    color: #8E8E93;
    margin-top: 2px;
}

/* Preview Messages */
.ios-preview-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ios-preview-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.ios-preview-message.from-lead {
    align-items: flex-start;
}

.ios-preview-message.from-user {
    align-items: flex-end;
    align-self: flex-end;
}

.ios-preview-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
}

.ios-preview-message.from-lead .ios-preview-message-bubble {
    background: rgba(142, 142, 147, 0.15);
    color: #000;
    border-bottom-left-radius: 4px;
}

.ios-preview-message.from-user .ios-preview-message-bubble {
    background: #007AFF;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ios-preview-message-time {
    font-size: 11px;
    color: #8E8E93;
    margin-top: 2px;
    padding: 0 4px;
}

/* Preview Actions */
.ios-preview-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    width: 100%;
    max-width: 400px;
    padding: 0 20px;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
}

.ios-preview-active .ios-preview-actions {
    transform: translateY(0);
    opacity: 1;
}

.ios-preview-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 500;
    color: #007AFF;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', 'Helvetica Neue', sans-serif;
}

.ios-preview-action:active {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.8);
}

.ios-preview-action-destructive {
    color: #FF3B30;
}

.ios-preview-action-icon {
    font-size: 18px;
}

/* Pressing State (before preview shows) */
.ios-preview-pressing {
    transform: scale(0.97);
    opacity: 0.8;
    transition: all 0.15s ease;
}

/* Source Element (when preview is active) */
.ios-preview-source {
    transform: scale(0.95);
    opacity: 0.5;
    transition: all 0.3s ease;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    .ios-preview-card {
        background: rgba(28, 28, 30, 0.98);
    }

    .ios-preview-header {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .ios-preview-header h3,
    .ios-preview-description,
    .ios-preview-field-value,
    .ios-preview-notes {
        color: #fff;
    }

    .ios-preview-avatar {
        background: #0A84FF;
    }

    .ios-preview-badge {
        background: rgba(10, 132, 255, 0.2);
        color: #0A84FF;
    }

    .ios-preview-stats {
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .ios-preview-stat-value {
        color: #0A84FF;
    }

    .ios-preview-message.from-lead .ios-preview-message-bubble {
        background: rgba(118, 118, 128, 0.24);
        color: #fff;
    }

    .ios-preview-message.from-user .ios-preview-message-bubble {
        background: #0A84FF;
    }

    .ios-preview-action {
        background: rgba(44, 44, 46, 0.95);
        color: #0A84FF;
    }

    .ios-preview-action:active {
        background: rgba(44, 44, 46, 0.8);
    }

    .ios-preview-action-destructive {
        color: #FF453A;
    }
}

.dark-mode .ios-preview-card {
    background: rgba(28, 28, 30, 0.98);
}

.dark-mode .ios-preview-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .ios-preview-header h3,
.dark-mode .ios-preview-description,
.dark-mode .ios-preview-field-value,
.dark-mode .ios-preview-notes {
    color: #fff;
}

.dark-mode .ios-preview-avatar {
    background: #0A84FF;
}

.dark-mode .ios-preview-badge {
    background: rgba(10, 132, 255, 0.2);
    color: #0A84FF;
}

.dark-mode .ios-preview-stats {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .ios-preview-stat-value {
    color: #0A84FF;
}

.dark-mode .ios-preview-message.from-lead .ios-preview-message-bubble {
    background: rgba(118, 118, 128, 0.24);
    color: #fff;
}

.dark-mode .ios-preview-message.from-user .ios-preview-message-bubble {
    background: #0A84FF;
}

.dark-mode .ios-preview-action {
    background: rgba(44, 44, 46, 0.95);
    color: #0A84FF;
}

.dark-mode .ios-preview-action:active {
    background: rgba(44, 44, 46, 0.8);
}

.dark-mode .ios-preview-action-destructive {
    color: #FF453A;
}

/* Responsive adjustments */
@media only screen and (max-width: 374px) {
    .ios-preview-card {
        max-width: calc(100vw - 32px);
    }

    .ios-preview-header {
        padding: 12px;
    }

    .ios-preview-body {
        padding: 12px;
    }

    .ios-preview-actions {
        padding: 0 16px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .ios-preview-card,
    .ios-preview-actions,
    .ios-preview-action,
    .ios-preview-pressing,
    .ios-preview-source {
        transition: none;
        animation: none;
    }

    .ios-preview-active .ios-preview-card,
    .ios-preview-active .ios-preview-actions {
        transform: none;
    }
}

/* Safe area support */
.ios-preview-actions {
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
}
