:root {
    --primary-color: #4F46E5;
    --secondary-color: #7C3AED;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --sidebar-width: 260px;
    --right-sidebar-width: 320px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--gray-200);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.logo i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

/* Navigation */
.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--gray-300);
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background: rgba(79, 70, 229, 0.2);
    color: white;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

.nav-item .badge {
    margin-left: auto;
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
}

/* Sidebar Sections */
.sidebar-section {
    padding: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-section h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--gray-400);
    margin-bottom: 1rem;
}

/* Tags */
.tag-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tag-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-300);
    text-decoration: none;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.tag-item:hover {
    color: white;
}

.tag-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.tag-item .count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Team */
.team-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.team-member {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.team-member:hover {
    color: white;
}

.team-member img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

/* Top Bar */
.top-bar {
    height: 60px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--gray-100);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    width: 400px;
}

.search-bar input {
    background: none;
    border: none;
    outline: none;
    flex: 1;
    font-size: 0.875rem;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--gray-600);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.user-menu:hover {
    background: var(--gray-100);
}

.user-menu img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* Conversation List */
.conversation-list {
    width: 400px;
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.list-header {
    padding: 1.5rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
}

.list-header h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.list-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: #4338CA;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

/* Conversations */
.conversations {
    flex: 1;
    overflow-y: auto;
    background: white;
}

.conversation-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.conversation-item:hover {
    background: var(--gray-50);
}

.conversation-item.active {
    background: #EEF2FF;
    border-left: 3px solid var(--primary-color);
}

.conversation-item.unread {
    background: #F0F9FF;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.conversation-from {
    font-weight: 600;
    color: var(--gray-900);
}

.conversation-time {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.conversation-subject {
    font-weight: 500;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.conversation-preview {
    font-size: 0.875rem;
    color: var(--gray-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    align-items: center;
}

.conversation-tags {
    display: flex;
    gap: 0.5rem;
}

.tag {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.tag-billing {
    background: #FEE2E2;
    color: #DC2626;
}

.tag-support {
    background: #DBEAFE;
    color: #2563EB;
}

.tag-sales {
    background: #FEF3C7;
    color: #D97706;
}

.conversation-assignee {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--gray-600);
}

.conversation-assignee img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

/* Conversation Detail */
.conversation-detail {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.detail-header {
    padding: 1.5rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
}

.detail-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.detail-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: var(--gray-50);
}

.message {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.message-from {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.message-from img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.message-info h4 {
    font-weight: 600;
}

.message-info p {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.message-body {
    line-height: 1.6;
    color: var(--gray-700);
}

.message-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

.message-actions button {
    font-size: 0.875rem;
    color: var(--gray-600);
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s;
}

.message-actions button:hover {
    color: var(--primary-color);
}

/* Reply Box */
.reply-box {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid var(--gray-200);
}

.reply-input {
    width: 100%;
    min-height: 100px;
    padding: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
    font-size: 0.875rem;
}

.reply-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.reply-tools {
    display: flex;
    gap: 0.5rem;
}

/* Right Sidebar */
.right-sidebar {
    width: var(--right-sidebar-width);
    background: white;
    border-left: 1px solid var(--gray-200);
    padding: 1.5rem;
    overflow-y: auto;
}

.contact-card {
    text-align: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--gray-200);
}

.contact-card img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 1rem;
}

.contact-card h4 {
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.contact-card p {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.info-section {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.info-section h4 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.assignee {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sla-good {
    color: var(--success-color);
    font-weight: 500;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.compose-field {
    margin-bottom: 1rem;
}

.compose-field label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.compose-field input,
.compose-field textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-family: inherit;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-500);
    cursor: pointer;
}

/* Demo Notice */
.demo-notice {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--warning-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    z-index: 100;
}

/* Responsive */
@media (max-width: 1200px) {
    .right-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .conversation-list {
        width: 100%;
    }
    
    .conversation-detail {
        position: fixed;
        top: 0;
        left: 100%;
        right: 0;
        bottom: 0;
        width: 100%;
        transition: left 0.3s;
    }
    
    .conversation-detail.active {
        left: 0;
    }
}