:root {
    --primary-color: #FFB347;
    --primary-dark: #FF9F1C;
    --primary-light: #FFD699;
    --primary-hover: #FFA500;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --bg-hover: #FFF3E0;
    --border-color: #E0E0E0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.menu-toggle span {
    width: 100%;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: var(--transition);
}

.logo {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.refresh-btn,
.generate-email-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.refresh-btn:hover,
.generate-email-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.refresh-btn:active,
.generate-email-btn:active {
    transform: translateY(0);
}

.refresh-btn svg {
    transition: transform 0.5s ease;
}

.refresh-btn.spinning svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 50;
}

.email-info {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.email-address {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    word-break: break-all;
}

.visitor-id {
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
    margin-bottom: 12px;
}

.copy-email-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.copy-email-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 179, 71, 0.3);
}

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

.copy-email-btn svg {
    flex-shrink: 0;
}

.copy-email-btn span {
    flex: 1;
}

.nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.nav-list {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--bg-hover);
}

.nav-item:active {
    transform: translateY(0);
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.nav-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.compose-email-item {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.compose-email-item:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 179, 71, 0.3);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
}

.toolbar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.email-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.email-list {
    width: 45%;
    min-width: 320px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 8px;
}

.email-item {
    padding: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    margin-bottom: 8px;
}

.email-item:hover {
    background: var(--bg-hover);
    border-color: var(--primary-light);
}

.email-item.active {
    background: linear-gradient(135deg, rgba(255, 179, 71, 0.1), rgba(255, 159, 28, 0.1));
    border-color: var(--primary-color);
}

.email-item.unread {
    background: var(--bg-primary);
    border-left: 3px solid var(--primary-color);
}

.email-item.unread .email-subject {
    font-weight: 600;
}

.email-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.email-from {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.email-time {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.email-subject {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-preview {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-detail {
    flex: 1;
    background: var(--bg-primary);
    overflow-y: auto;
    padding: 24px;
}

.detail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
}

.detail-placeholder svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.detail-content {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.detail-header {
    margin-bottom: 24px;
    position: relative;
}

.close-detail-btn {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

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

.detail-subject {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-right: 40px;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.meta-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.meta-value {
    color: var(--text-primary);
    font-weight: 500;
}

.detail-body {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
}

.detail-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 16px 0;
}

.detail-body a {
    color: var(--primary-dark);
    text-decoration: none;
    border-bottom: 1px solid var(--primary-light);
}

.detail-body a:hover {
    color: var(--primary-color);
}

.loading-state,
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    width: 100%;
}

.loading-state[style*="position: absolute"] {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 10;
}

.loading-state[style*="position: relative"] {
    position: relative;
    padding: 40px 20px;
    background: transparent;
}

.loading-state svg,
.empty-state svg,
.error-state svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--primary-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.retry-btn {
    margin-top: 16px;
    padding: 8px 24px;
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.retry-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.load-more-container {
    padding: 16px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.load-more-btn {
    padding: 10px 32px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.load-more-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.email-list {
    scroll-behavior: smooth;
}

.email-detail {
    scroll-behavior: smooth;
}

.email-item {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.batch-action-btn {
    -webkit-tap-highlight-color: transparent;
}

.load-more-btn {
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 1023px) {
    .header {
        padding: 12px 16px;
    }

    .menu-toggle {
        display: flex;
    }

    .logo {
        font-size: 20px;
    }

    .generate-email-btn span {
        display: none;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 60px;
        height: calc(100vh - 60px);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        left: 0;
    }

    .overlay.open {
        display: block;
        opacity: 1;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
    }

    .search-box {
        max-width: none;
    }

    .filter-actions {
        justify-content: space-between;
    }

    .email-container {
        flex-direction: column;
    }

    .email-list {
        width: 100%;
        min-width: auto;
        max-height: 50vh;
    }

    .email-detail {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    .email-detail.open {
        transform: translateX(0);
    }

    .detail-header {
        padding-right: 40px;
    }

    .close-detail-btn {
        display: flex;
    }

    .detail-meta {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 10px 12px;
    }

    .logo {
        font-size: 18px;
    }

    .refresh-btn,
    .generate-email-btn {
        padding: 6px 12px;
    }

    .refresh-btn svg,
    .generate-email-btn svg {
        width: 18px;
        height: 18px;
    }

    .toolbar {
        gap: 12px;
    }

    .search-box {
        padding: 10px 12px;
    }

    .search-box svg {
        width: 16px;
        height: 16px;
    }

    .filter-select {
        padding: 6px 10px;
        font-size: 13px;
    }

    .batch-action-btn {
        width: 32px;
        height: 32px;
    }

    .email-item {
        padding: 12px;
    }

    .email-from {
        font-size: 13px;
    }

    .email-subject {
        font-size: 13px;
    }

    .email-preview {
        font-size: 12px;
    }

    .email-detail {
        top: 56px;
    }

    .detail-subject {
        font-size: 18px;
    }

    .detail-meta {
        padding: 12px;
    }

    .meta-item {
        font-size: 13px;
    }

    .detail-body {
        font-size: 13px;
    }
}

@media (min-width: 1024px) {
    .sidebar {
        width: 25%;
    }

    .content-area {
        width: 75%;
    }

    .close-detail-btn {
        display: none;
    }
}