/*
 * iOS Theme Enhancements for VulnX
 * Implements iOS-style design elements, cards, and visual improvements
 */

/* iOS-Style Card System */
.ios-card {
    background: var(--ios-secondary-background);
    border-radius: var(--ios-radius-lg);
    padding: var(--ios-spacing-lg);
    margin-bottom: var(--ios-spacing-md);
    box-shadow: var(--ios-shadow-md);
    border: 1px solid var(--ios-separator);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.ios-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        rgba(255, 255, 255, 0.05) 50%, 
        rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

.ios-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ios-shadow-lg);
}

.ios-card:active {
    transform: translateY(0);
    box-shadow: var(--ios-shadow-sm);
}

/* iOS-Style Buttons */
.ios-button {
    background: var(--ios-blue);
    color: white;
    border: none;
    border-radius: var(--ios-radius-md);
    padding: var(--ios-spacing-md) var(--ios-spacing-lg);
    font-weight: 600;
    font-size: 1rem;
    min-height: var(--touch-target-min);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.ios-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent);
    transition: left 0.5s ease;
}

.ios-button:hover::before {
    left: 100%;
}

.ios-button:active {
    transform: scale(0.98);
}

.ios-button.secondary {
    background: var(--ios-background);
    color: var(--ios-blue);
    border: 1px solid var(--ios-separator);
}

.ios-button.destructive {
    background: var(--ios-red);
}

.ios-button.success {
    background: var(--ios-green);
}

/* iOS-Style Form Controls */
.ios-input {
    background: var(--ios-background);
    border: 1px solid var(--ios-separator);
    border-radius: var(--ios-radius-md);
    padding: var(--ios-spacing-md);
    font-size: 1rem;
    color: var(--ios-label);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: var(--touch-target-min);
    width: 100%;
    outline: none;
}

.ios-input:focus {
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.ios-input::placeholder {
    color: var(--ios-tertiary-label);
}

/* iOS-Style Segmented Control */
.ios-segmented-control {
    display: flex;
    background: var(--ios-background);
    border-radius: var(--ios-radius-md);
    padding: 2px;
    border: 1px solid var(--ios-separator);
    position: relative;
}

.ios-segmented-control input {
    display: none;
}

.ios-segmented-control label {
    flex: 1;
    text-align: center;
    padding: var(--ios-spacing-sm) var(--ios-spacing-md);
    cursor: pointer;
    transition: color 0.2s ease;
    position: relative;
    z-index: 2;
    font-weight: 500;
    color: var(--ios-label);
}

.ios-segmented-control input:checked + label {
    color: var(--ios-blue);
}

.ios-segmented-control::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    bottom: 2px;
    width: calc((100% - 4px) / var(--segment-count, 2));
    background: white;
    border-radius: calc(var(--ios-radius-md) - 2px);
    box-shadow: var(--ios-shadow-sm);
    transition: transform 0.2s ease;
    z-index: 1;
}

/* iOS-Style Toggle Switch */
.ios-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
}

.ios-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ios-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--ios-separator);
    border-radius: 16px;
    transition: background-color 0.2s ease;
}

.ios-toggle-slider::before {
    position: absolute;
    content: "";
    height: 28px;
    width: 28px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: var(--ios-shadow-sm);
}

.ios-toggle input:checked + .ios-toggle-slider {
    background: var(--ios-green);
}

.ios-toggle input:checked + .ios-toggle-slider::before {
    transform: translateX(20px);
}

/* iOS-Style Alert/Banner */
.ios-alert {
    background: var(--ios-secondary-background);
    border: 1px solid var(--ios-separator);
    border-radius: var(--ios-radius-lg);
    padding: var(--ios-spacing-lg);
    margin-bottom: var(--ios-spacing-lg);
    position: relative;
    backdrop-filter: blur(10px);
}

.ios-alert.info {
    background: rgba(0, 122, 255, 0.1);
    border-color: rgba(0, 122, 255, 0.3);
}

.ios-alert.success {
    background: rgba(52, 199, 89, 0.1);
    border-color: rgba(52, 199, 89, 0.3);
}

.ios-alert.warning {
    background: rgba(255, 149, 0, 0.1);
    border-color: rgba(255, 149, 0, 0.3);
}

.ios-alert.error {
    background: rgba(255, 59, 48, 0.1);
    border-color: rgba(255, 59, 48, 0.3);
}

.ios-alert-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: var(--ios-spacing-xs);
    color: var(--ios-label);
}

.ios-alert-message {
    color: var(--ios-secondary-label);
    line-height: 1.4;
}

/* iOS-Style List Items */
.ios-list {
    background: var(--ios-secondary-background);
    border-radius: var(--ios-radius-lg);
    overflow: hidden;
    border: 1px solid var(--ios-separator);
}

.ios-list-item {
    padding: var(--ios-spacing-lg);
    border-bottom: 1px solid var(--ios-separator);
    display: flex;
    align-items: center;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.ios-list-item:last-child {
    border-bottom: none;
}

.ios-list-item:hover {
    background: var(--ios-background);
}

.ios-list-item:active {
    background: var(--ios-tertiary-background);
}

.ios-list-item-icon {
    width: 32px;
    height: 32px;
    margin-right: var(--ios-spacing-md);
    border-radius: var(--ios-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.ios-list-item-content {
    flex: 1;
    min-width: 0;
}

.ios-list-item-title {
    font-weight: 500;
    color: var(--ios-label);
    margin-bottom: 2px;
}

.ios-list-item-subtitle {
    font-size: 0.875rem;
    color: var(--ios-secondary-label);
}

.ios-list-item-accessory {
    margin-left: var(--ios-spacing-md);
    color: var(--ios-tertiary-label);
}

/* iOS-Style Badge */
.ios-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    background: var(--ios-red);
    min-width: 20px;
    height: 20px;
}

.ios-badge.blue {
    background: var(--ios-blue);
}

.ios-badge.green {
    background: var(--ios-green);
}

.ios-badge.orange {
    background: var(--ios-orange);
}

.ios-badge.purple {
    background: var(--ios-purple);
}

/* iOS-Style Progress Bar */
.ios-progress {
    width: 100%;
    height: 4px;
    background: var(--ios-separator);
    border-radius: 2px;
    overflow: hidden;
}

.ios-progress-bar {
    height: 100%;
    background: var(--ios-blue);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* iOS-Style Loading Spinner */
.ios-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--ios-separator);
    border-top: 2px solid var(--ios-blue);
    border-radius: 50%;
    animation: ios-spin 1s linear infinite;
}

@keyframes ios-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* iOS-Style Modal/Sheet */
.ios-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ios-modal-overlay.show {
    opacity: 1;
}

.ios-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--ios-secondary-background);
    border-radius: var(--ios-radius-xl) var(--ios-radius-xl) 0 0;
    padding: var(--ios-spacing-xl);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
    max-height: 80vh;
    overflow-y: auto;
}

.ios-modal.show {
    transform: translateY(0);
}

.ios-modal-handle {
    width: 36px;
    height: 4px;
    background: var(--ios-separator);
    border-radius: 2px;
    margin: 0 auto var(--ios-spacing-lg);
}

/* iOS-Style Tab Bar */
.ios-tab-bar {
    display: flex;
    background: var(--ios-secondary-background);
    border-top: 1px solid var(--ios-separator);
    padding: var(--ios-spacing-sm) 0;
    backdrop-filter: blur(10px);
}

.ios-tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--ios-spacing-sm);
    text-decoration: none;
    color: var(--ios-tertiary-label);
    transition: color 0.2s ease;
    min-height: var(--touch-target-min);
    justify-content: center;
}

.ios-tab-item.active {
    color: var(--ios-blue);
}

.ios-tab-icon {
    font-size: 24px;
    margin-bottom: 2px;
}

.ios-tab-label {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Severity-specific iOS styling */
.severity-critical {
    background: linear-gradient(135deg, #8e24aa 0%, #ad1457 100%);
    color: white;
}

.severity-high {
    background: linear-gradient(135deg, #f44336 0%, #ff5722 100%);
    color: white;
}

.severity-medium {
    background: linear-gradient(135deg, #ff9800 0%, #ffc107 100%);
    color: white;
}

.severity-low {
    background: linear-gradient(135deg, #43a047 0%, #66bb6a 100%);
    color: white;
}

.severity-info {
    background: linear-gradient(135deg, #29b6f6 0%, #42a5f5 100%);
    color: white;
}

.severity-none {
    background: linear-gradient(135deg, #d2d2d2 0%, #bdbdbd 100%);
    color: #333;
}

/* KEV (Known Exploited Vulnerabilities) special styling */
.kev-badge {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    padding: 4px 8px;
    border-radius: var(--ios-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.kev-badge::before {
    content: '⚠️';
    font-size: 12px;
}

/* Apply iOS styling to existing VulnX components */
.vulnapi-card {
    background: var(--ios-secondary-background);
    border-radius: var(--ios-radius-lg);
    padding: var(--ios-spacing-lg);
    margin-bottom: var(--ios-spacing-md);
    box-shadow: var(--ios-shadow-md);
    border: 1px solid var(--ios-separator);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.vulnapi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ios-shadow-lg);
}

.cve-item {
    background: var(--ios-secondary-background);
    border-radius: var(--ios-radius-lg);
    padding: var(--ios-spacing-lg);
    margin-bottom: var(--ios-spacing-md);
    box-shadow: var(--ios-shadow-md);
    border: 1px solid var(--ios-separator);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.cve-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--ios-shadow-lg);
}

.filter-button {
    background: var(--ios-blue);
    color: white;
    border: none;
    border-radius: var(--ios-radius-md);
    padding: var(--ios-spacing-md) var(--ios-spacing-lg);
    font-weight: 600;
    font-size: 1rem;
    min-height: var(--touch-target-min);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.filter-button:active {
    transform: scale(0.98);
}

.filter-input {
    background: var(--ios-background);
    border: 1px solid var(--ios-separator);
    border-radius: var(--ios-radius-md);
    padding: var(--ios-spacing-md);
    font-size: 1rem;
    color: var(--ios-label);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: var(--touch-target-min);
    width: 100%;
    outline: none;
}

.filter-input:focus {
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Dark mode adjustments for iOS theme */
@media (prefers-color-scheme: dark) {
    .ios-card::before {
        background: linear-gradient(135deg, 
            rgba(255, 255, 255, 0.05) 0%, 
            rgba(255, 255, 255, 0.02) 50%, 
            rgba(255, 255, 255, 0) 100%);
    }
    
    .ios-toggle-slider::before {
        background: var(--ios-background);
    }
    
    .ios-modal {
        background: var(--ios-background);
    }
    
    .ios-tab-bar {
        background: var(--ios-background);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ios-card,
    .ios-button,
    .ios-input,
    .ios-toggle-slider,
    .ios-modal {
        transition: none;
    }
    
    .ios-spinner {
        animation: none;
    }
}
