/* 
 * WhatsApp2PDF - Styles
 * A privacy-first WhatsApp export to PDF converter
 */

/* ============================================
   CSS Custom Properties (Theme Variables)
   ============================================ */
:root {
    /* Color Palette - Light Theme */
    --bg-primary: #0a0f14;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2f5;
    --bg-chat: #efeae2;
    --bg-chat-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d1d7db' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    
    --text-primary: #111b21;
    --text-secondary: #54656f;
    --text-tertiary: #8696a0;
    
    --accent-primary: #00a884;
    --accent-secondary: #25d366;
    --accent-hover: #008f72;
    
    --bubble-outgoing: #d9fdd3;
    --bubble-incoming: #ffffff;
    --bubble-system: rgba(255, 255, 255, 0.9);
    
    --border-color: #e9edef;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    
    --header-bg: #008069;
    --header-text: #ffffff;
    
    /* Homepage specific - high contrast */
    --home-bg: #0a0f14;
    --home-text: #ffffff;
    --home-text-muted: #a0aec0;
    --home-card-bg: #151c24;
    --home-card-border: #2d3748;
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    
    --font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #111b21;
    --bg-secondary: #202c33;
    --bg-tertiary: #2a3942;
    --bg-chat: #0b141a;
    --bg-chat-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23182229' fill-opacity='0.6'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --text-tertiary: #667781;
    
    --accent-primary: #00a884;
    --accent-secondary: #25d366;
    --accent-hover: #06cf9c;
    
    --bubble-outgoing: #005c4b;
    --bubble-incoming: #202c33;
    --bubble-system: rgba(32, 44, 51, 0.95);
    
    --border-color: #2a3942;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    
    --header-bg: #202c33;
    --header-text: #e9edef;
    
    --home-bg: #0a0f14;
    --home-text: #ffffff;
    --home-text-muted: #a0aec0;
    --home-card-bg: #151c24;
    --home-card-border: #2d3748;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ============================================
   App Container & Layout
   ============================================ */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Header - Only visible in chat view
   ============================================ */
.header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

/* Hide header when on homepage */
.chat-only-header {
    display: none;
}

.chat-section ~ .chat-only-header,
.app-container:has(#chatSection[style*="flex"]) .chat-only-header {
    display: flex;
}

/* Show header when chat section is visible */
#chatSection[style*="flex"] ~ #mainHeader {
    display: flex;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

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

.logo-icon {
    width: 36px;
    height: 36px;
    color: var(--header-text);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

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

.theme-toggle, .github-link {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--header-text);
    transition: all var(--transition-fast);
}

.theme-toggle:hover, .github-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.theme-toggle svg, .github-link svg {
    width: 20px;
    height: 20px;
}

.sun-icon { display: none; }
.moon-icon { display: block; }

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }

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

/* ============================================
   Upload Section - High Contrast Dark Theme
   ============================================ */
.upload-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--home-bg);
    min-height: 100vh;
}

.upload-container {
    width: 100%;
    max-width: 800px;
    animation: fadeInUp 0.5s ease;
}

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

.upload-hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.hero-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
    color: var(--accent-primary);
}

.hero-logo svg {
    width: 100%;
    height: 100%;
}

.upload-hero h1 {
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--home-text);
    letter-spacing: -0.03em;
}

.upload-hero h1 .highlight-text {
    color: var(--accent-primary);
}

.tagline {
    color: var(--home-text-muted);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Dropzone */
.dropzone {
    background: var(--home-card-bg);
    border: 2px dashed var(--home-card-border);
    border-radius: var(--radius-xl);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.dropzone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.dropzone:hover, .dropzone.drag-over {
    border-color: var(--accent-primary);
    transform: scale(1.01);
    box-shadow: 0 0 40px rgba(0, 168, 132, 0.2);
}

.dropzone:hover::before, .dropzone.drag-over::before {
    opacity: 0.1;
}

.dropzone-content {
    position: relative;
    z-index: 1;
}

.dropzone-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
    color: var(--accent-primary);
}

.dropzone-icon svg {
    width: 100%;
    height: 100%;
}

.dropzone h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--home-text);
}

.dropzone p {
    color: var(--home-text-muted);
    margin-bottom: 0.75rem;
}

.folder-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
    opacity: 0.8;
}

.file-types {
    display: inline-block;
    background: rgba(0, 168, 132, 0.15);
    color: var(--accent-primary);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
}

/* Privacy Proof Section */
.privacy-proof {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--home-card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--home-card-border);
}


.proof-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.proof-item {
    display: flex;
    gap: 0.875rem;
    align-items: flex-start;
}

.proof-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: rgba(0, 168, 132, 0.15);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.proof-icon svg {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.proof-item strong {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--home-text);
    margin-bottom: 0.25rem;
}

.proof-item p {
    font-size: 0.8rem;
    color: var(--home-text-muted);
    line-height: 1.5;
    margin: 0;
}

.github-cta {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--home-card-border);
}

.github-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: var(--home-text);
    color: var(--home-bg);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.github-link-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15);
}

.github-link-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* How to Export */
.how-to-export {
    margin-top: 2.5rem;
    padding: 1.75rem;
    background: var(--home-card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--home-card-border);
}

.how-to-export h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--home-text);
}

.how-to-export ol {
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.how-to-export li {
    color: var(--home-text-muted);
    font-size: 0.9rem;
}

.how-to-export strong {
    color: var(--accent-primary);
    font-weight: 500;
}

/* ============================================
   Chat Section
   ============================================ */
.chat-section {
    display: flex;
    flex: 1;
    height: calc(100vh - 60px);
    overflow: hidden;
    background: var(--bg-primary);
}

/* Chat Sidebar */
.chat-sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    margin: 1rem;
    position: sticky;
    top: 70px;
    box-shadow: var(--shadow-md);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
}

.back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

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

.back-btn svg {
    width: 18px;
    height: 18px;
}

/* Chat Stats */
.chat-stats {
    padding: 1rem 1.25rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.5rem 0.625rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.stat-item:last-child {
    grid-column: 1 / -1;
}

.stat-label {
    font-size: 0.68rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Participants */
.participants-section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.participants-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.participant-hint {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.5;
    padding: 0.5rem 0.625rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-primary);
}

.whatsapp-limitations {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.whatsapp-limitations h3 {
    font-size: 0.72rem;
    font-weight: 700;
    color: #b45309;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

[data-theme="dark"] .whatsapp-limitations h3 {
    color: #fbbf24;
}

.limitation-item {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid #f59e0b;
}

.limitation-item:last-child {
    margin-bottom: 0;
}

.limitation-item strong {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.limitation-item p {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.participants-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    max-height: 180px;
    overflow-y: auto;
}

.participants-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
    border: 2px solid transparent;
    background: var(--bg-tertiary);
}

.participants-list li:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
}

.participants-list li.selected {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #00c896 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(0, 168, 132, 0.35);
}

.participants-list li.selected .participant-avatar {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    border: none;
}

.participants-list li.selected .participant-name,
.participants-list li.selected .participant-count {
    color: white;
}

.participants-list li.selected .participant-count {
    background: rgba(255, 255, 255, 0.25);
    font-weight: 600;
}

/* Fixed avatar colors - distinct from selected state */
.participant-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--accent-primary);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    transition: all var(--transition-fast);
}

.participant-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.participant-count {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Search Section */
.search-section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.date-filter-section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.date-filter-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.date-filter-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.date-filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-filter-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 36px;
    flex-shrink: 0;
}

.date-filter-input {
    flex: 1;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 0;
}

.date-filter-input:hover {
    border-color: var(--accent-primary);
}

.date-filter-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.15);
}

.date-filter-clear {
    width: 100%;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.date-filter-clear:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 0.6rem 1rem;
}

.search-input-wrapper svg {
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.search-input-wrapper input {
    flex: 1;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    outline: none;
}

.search-input-wrapper input::placeholder {
    color: var(--text-tertiary);
}

/* Export Section */
.export-section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
}

.export-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.export-btn svg {
    width: 18px;
    height: 18px;
}

.export-btn:hover {
    background: var(--bg-primary);
}

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

.export-btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Export Options */
.export-options {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.export-options h4 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
    padding: 0.5rem 0;
    user-select: none;
}

.toggle-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.toggle-option:hover .toggle-label {
    color: var(--text-primary);
}

/* ============================================
   Chat Main Area
   ============================================ */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 1rem;
    margin-left: 0;
}

.chat-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.chat-title-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-avatar svg {
    width: 24px;
    height: 24px;
}

.chat-title-text h3 {
    font-size: 1rem;
    font-weight: 600;
}

.chat-title-text span {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.action-btn svg {
    width: 20px;
    height: 20px;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-chat);
    background-image: var(--bg-chat-pattern);
    padding: 1rem;
}

.messages-list {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

/* Message Bubbles - Compact for printing */
.message {
    display: flex;
    flex-direction: column;
    max-width: 65%;
    animation: messageIn 0.2s ease;
}

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

.message.outgoing {
    align-self: flex-end;
}

.message.incoming {
    align-self: flex-start;
}

.message-bubble {
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-md);
    position: relative;
    box-shadow: var(--shadow-sm);
}

.message.call .message-bubble,
.message.missed_call .message-bubble {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.7rem;
}

.message.call .message-text,
.message.missed_call .message-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #f97316;
    font-size: 0.85rem;
}

.message.call .message-text::before {
    content: '';
    width: 16px;
    height: 16px;
    background: #f97316;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z'/%3E%3C/svg%3E") no-repeat center;
    mask-size: contain;
    flex-shrink: 0;
}

.message.missed_call .message-text::before {
    background: var(--text-error, #ef4444);
}

.message.outgoing .message-bubble {
    background: var(--bubble-outgoing);
    border-bottom-right-radius: 4px;
}

.message.incoming .message-bubble {
    background: var(--bubble-incoming);
    border-bottom-left-radius: 4px;
}

.message-sender {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 0.2rem;
}

/* Quoted/Reply Messages */
.quoted-message {
    background: rgba(0, 0, 0, 0.06);
    border-left: 3px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.4rem;
    font-size: 0.82rem;
}

[data-theme="dark"] .quoted-message {
    background: rgba(255, 255, 255, 0.08);
}

.quoted-sender {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 0.72rem;
    margin-bottom: 0.1rem;
}

.quoted-text {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.message-text {
    font-size: 0.88rem;
    line-height: 1.35;
    word-wrap: break-word;
}

.message-text a {
    color: #039be5;
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.15rem;
}

.message-time {
    font-size: 0.68rem;
    color: var(--text-tertiary);
}

/* Media in Messages */
.message-media {
    margin: 0.35rem 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-width: 280px;
}

.message-media img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.message-media img:hover {
    transform: scale(1.02);
}

.media-placeholder {
    background: var(--bg-tertiary);
    padding: 0.875rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

.media-placeholder svg {
    width: 28px;
    height: 28px;
    margin-bottom: 0.4rem;
    opacity: 0.5;
}

/* System Messages */
.message.system {
    align-self: center;
    max-width: 80%;
}

.message.system .message-bubble {
    background: var(--bubble-system);
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-lg);
}

/* Date Separators */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.75rem 0;
}

.date-separator span {
    background: var(--bubble-system);
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-lg);
    font-size: 0.78rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

/* ============================================
   Loading Overlay
   ============================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    background: var(--bg-secondary);
    padding: 2rem 3rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-spinner p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--accent-primary);
    color: white;
}

.modal-body {
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body input[type="date"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.btn-primary {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

/* ============================================
   Image Lightbox
   ============================================ */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    cursor: pointer;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .chat-section {
        flex-direction: column;
    }
    
    .chat-sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .message {
        max-width: 85%;
    }
    
    .proof-items {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .upload-section {
        padding: 1rem;
    }
    
    .dropzone {
        padding: 2rem 1rem;
    }
    
    .dropzone-icon {
        width: 56px;
        height: 56px;
    }
    
    .hero-logo {
        width: 56px;
        height: 56px;
    }
    
    .chat-sidebar {
        max-height: 35vh;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .header, .chat-sidebar, .loading-overlay, .modal {
        display: none !important;
    }
    
    .chat-section {
        height: auto;
    }
    
    .chat-main {
        height: auto;
    }
    
    .messages-container {
        overflow: visible;
        background: white;
        background-image: none;
    }
    
    .message {
        break-inside: avoid;
    }
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

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

/* ============================================
   Highlighted Search Results
   ============================================ */
.highlight {
    background: #fef08a;
    padding: 0 2px;
    border-radius: 2px;
}

[data-theme="dark"] .highlight {
    background: #854d0e;
}
