/**
 * MockTalks - Chat Screenshot Generator
 * Main Stylesheet - Organized for easy maintenance
 * https://mocktalks.com
 */

/* ===== IMPORTS & FONTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===== CSS RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root {
    /* Brand Colors */
    --color-primary: #00a884;
    --color-primary-dark: #008069;
    --color-primary-light: #e8f8f5;
    --color-secondary: #007AFF;
    --color-secondary-dark: #0051D5;
    --color-danger: #ef4444;
    --color-danger-dark: #dc2626;
    --color-success: #22c55e;
    --color-success-dark: #16a34a;
    
    /* Neutral Colors */
    --color-bg: #f8fafc;
    --color-bg-card: #ffffff;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;
    
    /* Authentic WhatsApp Colors */
    --whatsapp-green: #00a884;
    --whatsapp-light-green: #dcf8c6;
    --whatsapp-teal: #128c7e;
    --whatsapp-blue: #34b7f1;
    --whatsapp-gray: #999999;
    --whatsapp-dark-gray: #666666;
    --whatsapp-text: #000000;
    --whatsapp-received-bg: #ffffff;
    --whatsapp-chat-bg: #e5ddd5;
    --whatsapp-quote-border: #00a884;
    
    /* iOS Colors */
    --ios-blue: #007AFF;
    --ios-gray: #8e8e93;
    --ios-light-gray: rgba(248, 248, 248, 0.92);
    --ios-border: rgba(60, 60, 67, 0.12);
    --ios-blur-bg: rgba(248, 248, 248, 0.8);
    
    /* Layout */
    --container-max-width: 1280px;
    --phone-width: 390px;
    --phone-height: 844px;
    --border-radius: 12px;
    --border-radius-small: 8px;
    --border-radius-xs: 6px;
    --message-border-radius: 18px;
    --message-inner-radius: 6px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Typography - Authentic WhatsApp */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
    --font-size-message: 16px;
    --font-size-base: 17px;
    --font-size-small: 13px;
    --font-size-tiny: 11px;
    --letter-spacing: -0.08px;
    --line-height-message: 20px;

    /* CSS Variables for Dynamic Backgrounds */
    --ios-time: #ffffff;
    --whatsapp-header-bg: rgba(248, 248, 248, 0.94);
    --bubble-tail-bg: var(--whatsapp-chat-bg);
    --received-bubble-bg: #ffffff;
    --sent-bubble-bg: #dcf8c6;
    --received-bubble-color: #000000;
    --sent-bubble-color: #000000;
    --message-time-color: #667781;
    --sent-time-color: #4a6741;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--color-bg) 0%, #e2e8f0 100%);
    min-height: 100vh;
    padding: 24px;
    letter-spacing: var(--letter-spacing);
    line-height: 1.5;
    color: var(--color-text);
}

/* ===== LAYOUT ===== */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

/* ===== CONTROLS PANEL ===== */
.controls {
    flex: 1;
    min-width: 320px;
    max-width: 420px;
    background: var(--color-bg-card);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    height: fit-content;
    border: 1px solid var(--color-border-light);
}

/* Brand Header */
.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
}

.brand-icon {
    font-size: 32px;
    line-height: 1;
}

.controls-header h1 {
    text-align: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand-tagline {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.welcome-guide {
    background: linear-gradient(135deg, var(--color-primary-light) 0%, #f0fdf4 100%);
    border: 1px solid rgba(0, 168, 132, 0.2);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 24px;
}

.welcome-guide h4 {
    margin: 0 0 12px 0;
    color: var(--color-primary-dark);
    font-size: 15px;
    font-weight: 600;
}

.welcome-guide ul {
    margin: 0 0 16px 0;
    padding-left: 0;
    list-style: none;
    font-size: 13px;
    line-height: 1.6;
}

.welcome-guide li {
    margin-bottom: 6px;
    color: var(--color-text-secondary);
    padding-left: 8px;
    position: relative;
}

.welcome-guide li::before {
    content: "•";
    color: var(--color-primary);
    position: absolute;
    left: -4px;
}

.welcome-guide strong {
    color: var(--color-text);
    font-weight: 600;
}

.feature-highlights {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.feature-tag {
    background: white;
    color: var(--color-text-secondary);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--color-border);
}

.template-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.template-buttons .btn {
    font-size: 12px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.template-buttons .btn span {
    font-size: 14px;
}

/* Section Titles */
.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border-light);
}

.controls section {
    margin-bottom: 24px;
}

.controls h3 {
    margin-bottom: 15px;
    color: var(--color-text);
    font-weight: 600;
    letter-spacing: var(--letter-spacing);
}

/* ===== FORM COMPONENTS ===== */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--color-text);
    font-size: 13px;
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-small);
    font-size: 14px;
    font-family: var(--font-family);
    transition: all 0.2s ease;
    background: var(--color-bg-card);
    color: var(--color-text);
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.1);
}

.input-group input::placeholder,
.input-group textarea::placeholder {
    color: var(--color-text-muted);
}

.input-group textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.input-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.input-group-small {
    flex: 0 0 80px;
}

/* ===== BUTTONS ===== */
.btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--border-radius-small);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    text-decoration: none;
}

.btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-small {
    padding: 8px 12px;
    font-size: 12px;
}

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

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

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

.btn-secondary:hover {
    background: var(--color-secondary-dark);
}

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

.btn-danger:hover {
    background: var(--color-danger-dark);
}

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

.btn-success:hover {
    background: var(--color-success-dark);
}

.btn-outline {
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.btn-outline:hover {
    background: var(--color-bg);
    border-color: var(--color-text-muted);
    transform: translateY(-1px);
}

.btn-export {
    width: 100%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    padding: 16px 24px;
    font-size: 16px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.btn-export:hover {
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, #006652 100%);
    box-shadow: var(--shadow-lg);
}

.btn-icon {
    font-size: 18px;
}

.export-hint {
    text-align: center;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 8px;
}

/* ===== PROFILE UPLOAD ===== */
.profile-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.profile-preview {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e9e9eb 0%, #d1d5db 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--ios-gray);
    overflow: hidden;
    font-weight: 600;
    flex-shrink: 0;
    border: 2px solid var(--color-border-light);
}

.profile-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.profile-actions .btn {
    width: auto;
}

/* ===== MESSAGE INPUTS ===== */
.message-inputs {
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 12px;
    background: var(--color-bg);
    position: relative;
    transition: all 0.2s ease;
}

.message-inputs:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.message-actions {
    margin-top: 16px;
}

.message-actions .btn {
    width: 100%;
}

/* ===== FOOTER ===== */
.controls-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--color-border-light);
    margin-top: 8px;
}

.controls-footer p {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.controls-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.controls-footer a:hover {
    text-decoration: underline;
}

.privacy-note {
    font-size: 11px !important;
    color: var(--color-text-muted) !important;
}

/* ===== PHONE PREVIEW ===== */
.preview-container {
    flex: 1;
    min-width: var(--phone-width);
    display: flex;
    justify-content: center;
    position: sticky;
    top: 24px;
    height: fit-content;
}

.phone-preview {
    width: var(--phone-width);
    height: var(--phone-height);
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
    border-radius: 47px;
    padding: 4px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
    position: relative;
}

.phone-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 47px;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.02) 50%, rgba(255,255,255,0.05) 100%);
    pointer-events: none;
}

.screen {
    width: 100%;
    height: 100%;
    background: #ffffff;
    border-radius: 43px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* ===== iOS STATUS BAR - Authentic iPhone ===== */
.status-bar {
    height: 48px;
    background: rgba(248, 248, 248, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 17px 21px 0 21px;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.status-left {
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
    font-feature-settings: 'tnum';
    color: #000000;
}

.dynamic-island {
    position: absolute;
    top: 11px;
    left: 50%;
    transform: translateX(-50%);
    width: 126px;
    height: 30px;
    background: #000000;
    border-radius: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 5;
}

.dynamic-island-icon {
    width: 0px;
    height: 0px;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 0px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.2px;
    color: #000000;
}

/* ===== iOS SIGNAL & BATTERY ICONS - Authentic ===== */
.cellular-icon {
    width: 24px;
    height: 16px;
    flex-shrink: 0;
    color: #000;
    margin-right: 0px;
}



.network-type {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.24px;
    margin-right: 0px;
}
.wifi-icon {
    display: none;
    width: 0;
    height: 0;
    fill: #000;
    margin-right: 0;
}

.battery-icon {
    width: 50px;
    height: 24px;
    flex-shrink: 0;
    color: #000;
    margin-left: -5px;
    margin-right: -4px;
}



/* ===== WHATSAPP HEADER - Authentic iPhone ===== */
.whatsapp-header {
    height: 44px;
    background: rgba(248, 248, 248, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.12);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.back-section {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 4px;
    color: #000000;
}

.chevron-left {
    width: 11px;
    height: 20px;
    flex-shrink: 0;
    color: #000000;
}

.back-number {
    font-size: 17px;
    color: #000000;
    font-weight: 400;
    letter-spacing: -0.41px;
    line-height: 22px;
}

.profile-pic {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e9e9eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #8e8e93;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-size: 17px;
    font-weight: 600;
    color: #000000;
    letter-spacing: -0.41px;
    line-height: 22px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-status {
    font-size: 13px;
    color: #8e8e93;
    letter-spacing: -0.08px;
    line-height: 16px;
    margin-top: -2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.video-icon,
.phone-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: #000000;
}

/* ===== CHAT AREA - Multiple Background Options ===== */
.chat-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e5ddd5;
    background-image: 
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><g fill="%23d4cfc7" fill-opacity="0.4"><path d="M0 0h50v50H0zM50 50h50v50H50z"/></g></svg>');
    background-size: 100px 100px;
    background-position: center;
    background-repeat: repeat;
    z-index: 0;
}

.chat-content {
    position: relative;
    flex: 1;
    overflow-y: auto;
    padding: 8px 8px 8px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    z-index: 1;
}

/* Background Variations with Proper Variables */
.chat-background.bg-light {
    --whatsapp-chat-bg: #f7f7f7;
    --bubble-tail-bg: #f7f7f7;
    --received-bubble-bg: #ffffff;
    --sent-bubble-bg: #dcf8c6;
    --received-bubble-color: #000000;
    --sent-bubble-color: #000000;
    --message-time-color: #667781;
    --sent-time-color: #4a6741;
    
    background-color: var(--whatsapp-chat-bg);
    background-image: none;
}

.chat-background.bg-dark {
    --whatsapp-chat-bg: #0b141a;
    --bubble-tail-bg: #0b141a;
    --received-bubble-bg: #2a2f32;
    --sent-bubble-bg: #005c4b;
    --received-bubble-color: #e9edef;
    --sent-bubble-color: #e9edef;
    --message-time-color: #8696a0;
    --sent-time-color: #8696a0;
    
    background-color: var(--whatsapp-chat-bg);
    background-image: 
        radial-gradient(circle at 30% 40%, rgba(255, 255, 255, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.02) 0%, transparent 50%);
}

.chat-background.bg-doodle {
    --whatsapp-chat-bg: #e5ddd5;
    --bubble-tail-bg: #e5ddd5;
    --received-bubble-bg: #ffffff;
    --sent-bubble-bg: #dcf8c6;
    --received-bubble-color: #000000;
    --sent-bubble-color: #000000;
    --message-time-color: #667781;
    --sent-time-color: #4a6741;
    
    background-color: var(--whatsapp-chat-bg);
    background-image: 
        url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="doodle" x="0" y="0" width="30" height="30" patternUnits="userSpaceOnUse"><circle cx="5" cy="5" r="1" fill="%23d3d3d3" opacity="0.3"/><circle cx="25" cy="15" r="0.8" fill="%23d3d3d3" opacity="0.2"/><circle cx="15" cy="25" r="1.2" fill="%23d3d3d3" opacity="0.25"/></pattern></defs><rect width="100%" height="100%" fill="url(%23doodle)"/></svg>'),
        radial-gradient(circle at 20% 50%, rgba(120, 119, 116, 0.1) 0%, transparent 50%);
}

.chat-background.bg-geometric {
    --whatsapp-chat-bg: #e8e8e8;
    --bubble-tail-bg: #e8e8e8;
    --received-bubble-bg: #ffffff;
    --sent-bubble-bg: #dcf8c6;
    --received-bubble-color: #000000;
    --sent-bubble-color: #000000;
    --message-time-color: #667781;
    --sent-time-color: #4a6741;
    
    background-color: var(--whatsapp-chat-bg);
    background-image: 
        linear-gradient(30deg, transparent 24%, rgba(0,0,0,0.05) 25%, rgba(0,0,0,0.05) 26%, transparent 27%, transparent 74%, rgba(0,0,0,0.05) 75%, rgba(0,0,0,0.05) 76%, transparent 77%),
        linear-gradient(60deg, transparent 24%, rgba(0,0,0,0.05) 25%, rgba(0,0,0,0.05) 26%, transparent 27%, transparent 74%, rgba(0,0,0,0.05) 75%, rgba(0,0,0,0.05) 76%, transparent 77%);
    background-size: 30px 30px;
}

.chat-background.bg-custom {
    --bubble-tail-bg: var(--whatsapp-chat-bg);
    --received-bubble-bg: rgba(255, 255, 255, 0.95);
    --sent-bubble-bg: rgba(220, 248, 198, 0.95);
    --received-bubble-color: #000000;
    --sent-bubble-color: #000000;
    --message-time-color: #667781;
    --sent-time-color: #4a6741;
    
    background-color: var(--whatsapp-chat-bg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Dynamic date label for dark theme */
.chat-background.bg-dark .date-label {
    background: rgba(42, 47, 50, 0.9);
    color: #8696a0;
}

/* Quoted message styling for dark theme */
.chat-background.bg-dark .message-quote {
    background: rgba(0, 168, 132, 0.15);
    border-left: 3px solid #00d9ff;
}

.chat-background.bg-dark .message-quote .quoted-name {
    color: #00d9ff;
}

.chat-background.bg-dark .message-quote .quoted-text {
    color: rgba(233, 237, 239, 0.7);
}

/* Dark mode bubble border adjustments */
.chat-background.bg-dark .message-bubble.received {
    border: 0.5px solid rgba(255, 255, 255, 0.1);
}

.chat-background.bg-dark .message-bubble.sent {
    border: 0.5px solid rgba(255, 255, 255, 0.05);
}

/* Custom background bubble adjustments for better visibility */
.chat-background.bg-custom .message-bubble.received {
    border: 0.5px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.chat-background.bg-custom .message-bubble.sent {
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.messages-container {
    padding: 0 8px;
    padding-bottom: 16px;
    position: relative;
    z-index: 1;
}

/* ===== DATE SEPARATOR - Refined ===== */
.date-separator {
    text-align: center;
    margin: 12px 0 8px;
}

.date-label {
    display: inline-block;
    background: rgba(255, 255, 255, 0.95);
    color: #667781;
    font-size: 10.5px;
    padding: 3px 12px;
    border-radius: 9px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    letter-spacing: -0.05px;
    font-weight: 500;
}

/* ===== MESSAGE BUBBLES - Authentic WhatsApp Design ===== */
.message-wrapper {
    display: flex;
    margin-bottom: 2px;
    padding: 0 8px;
}

.message-wrapper.sent {
    justify-content: flex-end;
}

.message-wrapper.received {
    justify-content: flex-start;
}

/* Spacing between message groups */
.message-wrapper:has(+ .message-wrapper .message-bubble.first-in-sequence) {
    margin-bottom: 12px;
}

/* First message in sequence */
.message-wrapper .message-bubble.first-in-sequence {
    margin-top: 0;
}

/* Grouped messages */
.message-wrapper .message-bubble:not(.first-in-sequence) {
    margin-top: 0;
}

/* Consecutive messages from same person */
.message-wrapper + .message-wrapper .message-bubble:not(.first-in-sequence) {
    margin-top: 0;
}

/* ===== QUOTED MESSAGE STYLING - Authentic WhatsApp ===== */
.message-quote {
    background: rgba(0, 168, 132, 0.1);
    border-left: 3px solid #00a884;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 14px;
    position: relative;
}

.message-quote .quoted-name {
    font-weight: 600;
    color: #00a884;
    font-size: 13px;
    margin-bottom: 3px;
    line-height: 16px;
    letter-spacing: -0.08px;
}

.message-quote .quoted-text {
    font-size: 14px;
    line-height: 18px;
    color: rgba(0, 0, 0, 0.65);
    font-weight: 400;
    letter-spacing: -0.05px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.message-bubble {
    position: relative;
    max-width: 280px;
    margin-bottom: 2px;
    padding: 6px 12px 8px 12px;
    line-height: 20px;
    word-wrap: break-word;
    word-break: break-word;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    animation: messageSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: bottom;
    font-weight: 400;
    overflow: visible;
}

.message-bubble.received {
    align-self: flex-start;
    background: #ffffff;
    color: #000000;
    padding: 6px 12px 8px 12px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.message-bubble.sent {
    align-self: flex-end;
    background: #dcf8c6;
    color: #000000;
    padding: 6px 12px 8px 12px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

/* WhatsApp bubble corner radius - authentic curved tails matching real WhatsApp */
/* Received messages - precise authentic styling */
.message-bubble.received.first-in-sequence {
    border-radius: 16px 16px 16px 16px;
}
.message-bubble.received:not(.last-in-sequence):not(.first-in-sequence) {
    border-radius: 16px 16px 16px 16px;
}
.message-bubble.received.last-in-sequence:not(.first-in-sequence) {
    border-radius: 16px 16px 16px 8px;
}
.message-bubble.received.first-in-sequence.last-in-sequence {
    border-radius: 16px 16px 16px 8px;
}

/* Sent messages - precise authentic styling */
.message-bubble.sent.first-in-sequence {
    border-radius: 16px 16px 16px 16px;
}
.message-bubble.sent:not(.last-in-sequence):not(.first-in-sequence) {
    border-radius: 16px 16px 16px 16px;
}
.message-bubble.sent.last-in-sequence:not(.first-in-sequence) {
    border-radius: 16px 16px 8px 16px;
}
.message-bubble.sent.first-in-sequence.last-in-sequence {
    border-radius: 16px 16px 8px 16px;
}

/* Authentic WhatsApp SVG tail effect using custom tail.svg - realistic design */
.message-bubble.received.last-in-sequence,
.message-bubble.received.first-in-sequence.last-in-sequence {
    position: relative;
}

.message-bubble.received.last-in-sequence::after,
.message-bubble.received.first-in-sequence.last-in-sequence::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: -8px;
    width: 12px;
    height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26.7 41.63"><g transform="scale(-1,1) translate(-26.7,0)"><path d="M26.2,39.05c.09-.81-1.38-1.3-4.77-3.67,0,0-1.13-.79-3.95-3.02-5.93-4.69-7.14-17.06-7.44-20.11-.64-6.52-.14-11.74-.37-11.75-.46-.02,1.29,21.5-7.27,29.19-.58.52-1.93,1.63-1.91,3.12.07,3.86,9.34,6.47,12.11,7.34,1.43.45,4.05,1.15,7.35.95,2.24-.14,6.1-.78,6.24-2.05Z" fill="%23ffffff"/></g></svg>');
    background-size: 12px 20px;
    background-repeat: no-repeat;
    background-position: bottom left;
}

.message-bubble.sent.last-in-sequence,
.message-bubble.sent.first-in-sequence.last-in-sequence {
    position: relative;
}

.message-bubble.sent.last-in-sequence::after,
.message-bubble.sent.first-in-sequence.last-in-sequence::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -8px;
    width: 12px;
    height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26.7 41.63"><path d="M26.2,39.05c.09-.81-1.38-1.3-4.77-3.67,0,0-1.13-.79-3.95-3.02-5.93-4.69-7.14-17.06-7.44-20.11-.64-6.52-.14-11.74-.37-11.75-.46-.02,1.29,21.5-7.27,29.19-.58.52-1.93,1.63-1.91,3.12.07,3.86,9.34,6.47,12.11,7.34,1.43.45,4.05,1.15,7.35.95,2.24-.14,6.1-.78,6.24-2.05Z" fill="%23dcf8c6"/></svg>');
    background-size: 12px 20px;
    background-repeat: no-repeat;
    background-position: bottom right;
}

/* Custom SVG tails using inline data URIs - reliable and authentic design */

/* Dark theme tail variants */
.chat-background.bg-dark .message-bubble.received.last-in-sequence::after,
.chat-background.bg-dark .message-bubble.received.first-in-sequence.last-in-sequence::after {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26.7 41.63"><g transform="scale(-1,1) translate(-26.7,0)"><path d="M26.2,39.05c.09-.81-1.38-1.3-4.77-3.67,0,0-1.13-.79-3.95-3.02-5.93-4.69-7.14-17.06-7.44-20.11-.64-6.52-.14-11.74-.37-11.75-.46-.02,1.29,21.5-7.27,29.19-.58.52-1.93,1.63-1.91,3.12.07,3.86,9.34,6.47,12.11,7.34,1.43.45,4.05,1.15,7.35.95,2.24-.14,6.1-.78,6.24-2.05Z" fill="%232a2f32"/></g></svg>');
}

.chat-background.bg-dark .message-bubble.sent.last-in-sequence::after,
.chat-background.bg-dark .message-bubble.sent.first-in-sequence.last-in-sequence::after {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26.7 41.63"><path d="M26.2,39.05c.09-.81-1.38-1.3-4.77-3.67,0,0-1.13-.79-3.95-3.02-5.93-4.69-7.14-17.06-7.44-20.11-.64-6.52-.14-11.74-.37-11.75-.46-.02,1.29,21.5-7.27,29.19-.58.52-1.93,1.63-1.91,3.12.07,3.86,9.34,6.47,12.11,7.34,1.43.45,4.05,1.15,7.35.95,2.24-.14,6.1-.78,6.24-2.05Z" fill="%23005c4b"/></svg>');
}





/* Message text: larger and bolder */
.text-with-inline-time {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    width: 100%;
    min-height: 20px;
    gap: 10px;
}
.text-with-inline-time > .message-text {
    flex: 1;
    min-width: 0;
}

.message-text {
    font-size: 15px;
    line-height: 20px;
    color: #000000;
    word-wrap: break-word;
    font-weight: 400;
    letter-spacing: -0.05px;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
}

.message-content-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0;
    padding: 0;
}

.text-with-inline-time {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    width: 100%;
    min-height: 22px;
    gap: 12px;
}

.text-with-inline-time > .message-text {
    flex: 1;
    min-width: 0;
}

.message-image {
    max-width: 250px;
    max-height: 300px;
    width: auto;
    height: auto;
    border-radius: 12px;
    margin-bottom: 4px;
    display: block;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    object-fit: cover;
    background-color: #f0f0f0;
}

/* Image container for positioning metadata overlay */
.image-container {
    position: relative;
    display: inline-block;
}

/* Image message metadata styling - inline overlay */
.message-meta.image-meta.inline {
    position: absolute;
    bottom: 6px;
    right: 6px;
    color: #ffffff;
    padding: 2px 6px;
    font-size: 11px;
    line-height: 14px;
    margin: 0;
    min-height: auto;
    gap: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}



/* White timestamp for image overlays */
.message-meta.image-meta.inline .message-time {
    color: #ffffff;
    font-size: 11px;
    line-height: 14px;
}

/* Traditional message metadata (below text) */
.message-meta {
    display: flex;
    align-items: center;
    gap: 3px;
    justify-content: flex-end;
    margin-top: 2px;
    min-height: 15px;
    flex-shrink: 0;
    padding-left: 40px;
}

/* Inline message metadata (next to text for single-line messages) */
.message-meta.inline {
    display: inline-flex;
    align-items: flex-end;
    gap: 3px;
    margin-top: 0;
    min-height: auto;
    padding-left: 0;
    padding-right: 0;
    margin-left: 0;
    flex-shrink: 0;
    vertical-align: baseline;
    position: relative;
    z-index: 1;
}

.message-time {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.45);
    letter-spacing: -0.05px;
    line-height: 11px;
    font-weight: 400;
    white-space: nowrap;
}

/* Sent message timestamp color */
.message-bubble.sent .message-time {
    color: rgba(0, 0, 0, 0.45);
}

/* Inline timestamp styling */
.message-meta.inline .message-time {
    font-size: 11px;
    line-height: 11px;
}

.checkmarks {
    width: 16px;
    height: 11px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
    overflow: visible;
}

/* Inline checkmarks styling */
.message-meta.inline .checkmarks {
    vertical-align: baseline;
    margin-top: 0;
    margin-bottom: 0;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

/* Single checkmark - sent */
.checkmarks.sent {
    width: 15px;
    color: rgba(0, 0, 0, 0.45);
}

/* Double checkmarks - delivered */
.checkmarks.delivered {
    width: 16px;
    color: rgba(0, 0, 0, 0.45);
}

/* Double checkmarks - read */
.checkmarks.read {
    width: 16px;
    color: #53bdeb;
}

/* ===== INPUT BAR - Authentic iPhone ===== */
.input-bar {
    height: 50px;
    background: rgba(248, 248, 248, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    display: flex;
    align-items: center;
    padding: 7px 16px;
    margin-bottom: 20px;
    gap: 8px;
    border-top: 0.5px solid rgba(60, 60, 67, 0.12);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.input-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8e8e93;
    flex-shrink: 0;
}

.plus-icon {
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
}

.input-field {
    flex: 1;
    height: 30px;
    background: #ffffff;
    border-radius: 18px;
    border: 0.5px solid rgba(60, 60, 67, 0.12);
    padding: 8px 16px;
    font-size: 17px;
    display: flex;
    align-items: center;
    color: #8e8e93;
    letter-spacing: -0.41px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
}

/* ===== HOME INDICATOR - Authentic ===== */
.home-indicator {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 134px;
    height: 5px;
    background: #000000;
    border-radius: 2.5px;
    opacity: 0.3;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 900px) {
    body {
        padding: 16px;
    }
    
    .container {
        flex-direction: column;
        gap: 24px;
        align-items: center;
    }
    
    .controls {
        min-width: auto;
        max-width: 100%;
        width: 100%;
        order: 2;
    }
    
    .preview-container {
        position: static;
        min-width: auto;
        order: 1;
    }
    
    .phone-preview {
        transform: scale(0.85);
        margin: -40px auto;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }
    
    .phone-preview {
        transform: scale(0.75);
        margin: -60px auto;
    }
    
    .template-buttons {
        grid-template-columns: 1fr;
    }
    
    .input-row {
        flex-direction: column;
    }
    
    .input-group-small {
        flex: 1;
    }
}

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== ANIMATIONS - Enhanced ===== */
@keyframes messageSlideIn {
    0% {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    60% {
        opacity: 0.8;
        transform: scale(1.02) translateY(-2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.message-bubble {
    animation: messageSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Staggered animation for multiple messages */
.message-bubble:nth-child(2) { animation-delay: 0.1s; }
.message-bubble:nth-child(3) { animation-delay: 0.2s; }
.message-bubble:nth-child(4) { animation-delay: 0.3s; }
.message-bubble:nth-child(5) { animation-delay: 0.4s; }

/* Date separator animation */
.date-separator {
    animation: fadeInDown 0.5s ease-out;
}

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

/* ===== TYPING INDICATOR ANIMATIONS ===== */
.typing-indicator {
    margin-bottom: 8px;
}

.typing-bubble {
    background-color: var(--received-bubble-bg);
    padding: 16px 12px;
    min-height: auto;
    width: auto;
    display: inline-block;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 8px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #999;
    opacity: 0.4;
    animation: none;
}

.typing-dot.animate {
    animation: typingDot 1.4s infinite ease-in-out both;
}

.typing-dot.animate:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot.animate:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dot.animate:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typingDot {
    0%, 80%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ===== MESSAGE ENTRANCE ANIMATIONS ===== */
.message-wrapper {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.message-wrapper.entering {
    opacity: 0;
    transform: translateY(10px);
}

.date-separator {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.date-separator.entering {
    opacity: 0;
    transform: translateY(10px);
} 