/* Apple-Inspired Design System */
:root {
    /* Colors - Apple Blue Palette */
    --primary: #007AFF;
    --primary-hover: #0051D5;
    --primary-light: rgba(0, 122, 255, 0.1);

    /* Status Colors */
    --status-pending: #FF9500;
    --status-pending-bg: rgba(255, 149, 0, 0.1);
    --status-processed: #34C759;
    --status-processed-bg: rgba(52, 199, 89, 0.1);

    /* Danger */
    --danger: #FF3B30;
    --danger-hover: #D70015;

    /* Neutrals */
    --background: #F5F5F7;
    --surface: #FFFFFF;
    --border: rgba(0, 0, 0, 0.08);
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --text-tertiary: #C7C7CC;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);

    /* Spacing */
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #000000;
        --surface: #1C1C1E;
        --border: rgba(255, 255, 255, 0.1);
        --text-primary: #F5F5F7;
        --text-secondary: #98989D;
        --text-tertiary: #48484A;
    }
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-xl);
}

/* Header */
.header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-xl) 0;
}

.header h1 {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: var(--spacing-sm);
    background: linear-gradient(135deg, var(--primary) 0%, #5856D6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    background: var(--surface);
    padding: 6px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.tab-button {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
}

.tab-button:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.tab-button.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

.tab-button:not(.active) .count {
    background: var(--background);
    color: var(--text-secondary);
}

.tab-button:not(.active) .count.pending {
    background: var(--status-pending-bg);
    color: var(--status-pending);
}

.tab-button:not(.active) .count.processed {
    background: var(--status-processed-bg);
    color: var(--status-processed);
}

/* Messages Container */
.messages-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.messages-list {
    display: flex;
    flex-direction: column;
}

/* Message Card */
.message-card {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.message-card:last-child {
    border-bottom: none;
}

.message-card:hover {
    background: var(--background);
}

.message-card:active {
    transform: scale(0.995);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-sm);
}

.message-title {
    flex: 1;
}

.message-title h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.message-meta {
    font-size: 14px;
    color: var(--text-secondary);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge.pending {
    background: var(--status-pending-bg);
    color: var(--status-pending);
}

.status-badge.processed {
    background: var(--status-processed-bg);
    color: var(--status-processed);
}

.message-preview {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Empty State */
.empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-lg);
    color: var(--text-tertiary);
    text-align: center;
}

.empty-state.show {
    display: flex;
}

.empty-state svg {
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state p {
    font-size: 17px;
    font-weight: 500;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

.modal.show {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 600;
}

.close-button {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--background);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.close-button:hover {
    background: var(--border);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
}

.detail-group {
    margin-bottom: var(--spacing-lg);
}

.detail-group:last-child {
    margin-bottom: 0;
}

.detail-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-xs);
}

.detail-group p {
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.5;
}

.message-content {
    white-space: pre-wrap;
    background: var(--background);
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
}

.timestamp {
    font-size: 14px !important;
    color: var(--text-secondary) !important;
}

.status-control {
    display: flex;
    align-items: center;
}

.modal-footer {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border);
}

/* Login Modal */
.login-modal {
    max-width: 400px;
}

.password-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: var(--font-family);
    background: var(--background);
    color: var(--text-primary);
    transition: all 0.2s;
    margin-top: var(--spacing-xs);
}

.password-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}

.error-message {
    color: var(--danger);
    font-size: 14px;
    margin-top: var(--spacing-xs);
    min-height: 20px;
}

/* Action Buttons */
.action-button {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-family);
}

.action-button.primary {
    background: var(--primary);
    color: white;
}

.action-button.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.action-button.secondary {
    background: var(--background);
    color: var(--text-primary);
}

.action-button.secondary:hover {
    background: var(--border);
}

.action-button.danger {
    background: var(--danger);
    color: white;
}

.action-button.danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-button.full-width {
    width: 100%;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-md);
    }

    .header h1 {
        font-size: 36px;
    }

    .filter-tabs {
        flex-direction: column;
    }

    .modal-content {
        max-height: 95vh;
        border-radius: var(--radius-lg);
    }

    .modal-footer {
        flex-direction: column;
    }
}

/* Smooth Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}