* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000000;
    min-height: 100vh;
    padding: 20px;
    direction: ltr;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 0, 0, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(0, 0, 255, 0.02) 0%, transparent 50%);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: #0d0d0d;
    border-radius: 20px;
    box-shadow: 
        0 0 80px rgba(120, 119, 198, 0.15),
        0 20px 60px rgba(0, 0, 0, 0.9),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    overflow: hidden;
    display: flex;
    height: 90vh;
    border: 1px solid rgba(120, 119, 198, 0.2);
}

.sidebar {
    width: 400px;
    background: linear-gradient(180deg, #0f0f0f 0%, #0a0a0a 100%);
    border-right: 1px solid rgba(120, 119, 198, 0.15);
    display: flex;
    flex-direction: column;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.02);
}

.header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: white;
    padding: 25px 20px;
    text-align: center;
    position: relative;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(120, 119, 198, 0.2);
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #7877c6, transparent);
}

.header h1 {
    font-size: 20px;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.header p {
    font-size: 11px;
    opacity: 0.7;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.search-box {
    padding: 20px;
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
}

.search-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid rgba(120, 119, 198, 0.2);
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
    background: rgba(26, 26, 26, 0.6);
    color: #e0e0e0;
    backdrop-filter: blur(10px);
}

.search-input::placeholder {
    color: #6a6a6a;
}

.search-input:focus {
    border-color: #7877c6;
    box-shadow: 
        0 0 0 3px rgba(120, 119, 198, 0.1),
        0 0 20px rgba(120, 119, 198, 0.2);
    background: rgba(26, 26, 26, 0.8);
}

.filters {
    padding: 15px 20px;
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    gap: 10px;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid rgba(120, 119, 198, 0.2);
    background: rgba(26, 26, 26, 0.6);
    border-radius: 20px;
    font-size: 13px;
    color: #b0b0b0;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.filter-btn:hover {
    background: rgba(58, 58, 58, 0.8);
    color: #e0e0e0;
    border-color: #7877c6;
    box-shadow: 0 0 15px rgba(120, 119, 198, 0.2);
}

.filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #7877c6;
    box-shadow: 
        0 0 20px rgba(120, 119, 198, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.message-item {
    padding: 15px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.6) 0%, rgba(20, 20, 20, 0.8) 100%);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid rgba(120, 119, 198, 0.1);
    backdrop-filter: blur(10px);
}

.message-item:hover {
    border-color: #7877c6;
    background: linear-gradient(135deg, rgba(30, 30, 30, 0.8) 0%, rgba(25, 25, 25, 0.9) 100%);
    transform: translateX(5px);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(120, 119, 198, 0.15);
}

.message-item.active {
    border-color: #7877c6;
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.3) 0%, rgba(26, 26, 26, 0.8) 100%);
    box-shadow: 
        0 0 20px rgba(120, 119, 198, 0.2),
        inset 0 0 20px rgba(120, 119, 198, 0.05);
}

.message-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.message-item-type {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.message-item-type.imessage {
    background: #1e4d2b;
    color: #a3e4b8;
}

.message-item-type.email {
    background: #1e3a5a;
    color: #85c1ff;
}

.message-item-type.text {
    background: #4a3c1e;
    color: #ffd966;
}

.message-item-filename {
    font-size: 12px;
    color: #888;
}

.message-item-title {
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 5px;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-item-preview {
    font-size: 12px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-item-date {
    font-size: 11px;
    color: #777;
    margin-top: 5px;
}

.viewer-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
}

.viewer-header {
    padding: 20px 30px;
    background: #1e1e1e;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.translate-select {
    padding: 8px 15px;
    background: rgba(26, 26, 26, 0.8);
    border: 1px solid rgba(120, 119, 198, 0.3);
    border-radius: 20px;
    color: #e0e0e0;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: all 0.3s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.translate-select:hover {
    background: rgba(120, 119, 198, 0.2);
    border-color: rgba(120, 119, 198, 0.5);
}

.translate-select:focus {
    border-color: #7877c6;
    box-shadow: 0 0 0 3px rgba(120, 119, 198, 0.1);
}

.translate-select option {
    background: #1a1a1a;
    color: #e0e0e0;
    padding: 10px;
}

.viewer-title {
    font-size: 20px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 10px;
}

.viewer-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 13px;
    color: #888;
}

.viewer-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.viewer-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: #0a0a0a;
    /* iMessage Background Pattern */
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(120, 119, 198, 0.01) 2px,
            rgba(120, 119, 198, 0.01) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(120, 119, 198, 0.01) 2px,
            rgba(120, 119, 198, 0.01) 4px
        );
    position: relative;
}

.viewer-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 30% 30%, rgba(120, 119, 198, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(255, 0, 0, 0.01) 0%, transparent 50%);
    pointer-events: none;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 16px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* iMessage Styles */
.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    align-items: flex-end;
}

.message.received {
    align-items: flex-start;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #6c757d;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.message.sent .avatar {
    border-color: #e9ecef;
}

.message.received .avatar {
    border-color: #007aff;
}

.sender-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.sender-name {
    font-weight: 600;
    color: #b0b0b0;
}

.message-time {
    color: #666;
}

.message-bubble {
    max-width: 70%;
    padding: 16px 24px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
    font-size: 19px;
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, #1a1a1a 0%, #252525 100%);
    color: #e0e0e0;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(120, 119, 198, 0.1);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.message.received .message-bubble {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    color: white;
    border-bottom-left-radius: 4px;
    box-shadow: 
        0 2px 8px rgba(30, 58, 138, 0.4),
        0 0 20px rgba(30, 58, 138, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(120, 119, 198, 0.2);
}

.date-separator {
    text-align: center;
    margin: 30px 0 20px 0;
    position: relative;
}

.date-separator::before,
.date-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(120, 119, 198, 0.3),
        transparent
    );
}

.date-separator::before {
    left: 0;
}

.date-separator::after {
    right: 0;
}

.date-separator span {
    background: rgba(10, 10, 10, 0.9);
    padding: 5px 15px;
    color: #888;
    font-size: 13px;
    font-weight: 600;
    border-radius: 15px;
    border: 1px solid rgba(120, 119, 198, 0.2);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* Email Styles */
.email-container {
    background: #1a1a1a;
}

.email-header {
    padding: 20px;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.8) 0%, rgba(20, 20, 20, 0.9) 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid rgba(120, 119, 198, 0.15);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.email-subject {
    font-size: 24px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 15px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.email-meta {
    display: grid;
    gap: 10px;
    font-size: 14px;
}

.email-meta-row {
    display: flex;
    gap: 10px;
}

.email-meta-label {
    font-weight: 600;
    color: #b0b0b0;
    min-width: 80px;
}

.email-meta-value {
    color: #888;
}

.email-body {
    line-height: 1.8;
    color: #d0d0d0;
    white-space: pre-wrap;
    font-size: 15px;
}

.email-disclaimer {
    font-size: 10px;
    color: #666;
    line-height: 1.4;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #2a2a2a;
    opacity: 0.6;
}

.email-thread {
    background: #f8f9fa;
    padding: 15px;
    margin: 20px 0;
    border-left: 4px solid #667eea;
    border-radius: 8px;
}

.email-thread-header {
    font-size: 12px;
    color: #888;
    margin-bottom: 10px;
    font-weight: 600;
}

/* Plain Text Styles */
.text-container {
    background: #1a1a1a;
    padding: 20px;
}

.text-header {
    padding: 20px;
    background: #2a2a2a;
    border-radius: 10px;
    margin-bottom: 20px;
}

.text-filename {
    font-size: 20px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 10px;
}

.text-body {
    line-height: 1.8;
    color: #d0d0d0;
    white-space: pre-wrap;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.stats {
    padding: 15px 20px;
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
    font-size: 13px;
    color: #888;
    display: flex;
    justify-content: space-between;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 
        0 4px 20px rgba(102, 126, 234, 0.4),
        0 0 40px rgba(120, 119, 198, 0.3);
    transition: all 0.3s ease;
    /* Safari-specific fixes */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
}

@media (max-width: 1024px) {
    .sidebar {
        width: 350px;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: auto;
        min-height: 90vh;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        z-index: 999;
        border-radius: 20px 20px 0 0;
    }
    
    .sidebar.mobile-open {
        max-height: 80vh;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.8);
    }
    
    .viewer-panel {
        min-height: 90vh;
    }
    
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .message-bubble {
        max-width: 85%;
        font-size: 16px;
    }
}
