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

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --bg-chat: #0f0f0f;
    --text-primary: #ffffff;
    --text-secondary: #b4b4b4;
    --text-tertiary: #808080;
    --accent-primary: #00a884;
    --accent-hover: #008f6f;
    --accent-light: rgba(0, 168, 132, 0.1);
    --border-color: #2a2a2a;
    --message-user: #005c4b;
    --message-ai: #1f1f1f;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Mobile Header */
.mobile-header {
    display: none;
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-btn,
.header-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.back-btn:hover,
.header-menu-btn:hover {
    background: var(--bg-tertiary);
}

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

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #00d9a8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.header-text h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.online-status {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 200;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-primary);
}

.sidebar-logo i {
    font-size: 28px;
}

.close-sidebar {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-sidebar:hover {
    background: var(--bg-tertiary);
}

.new-chat-btn {
    margin: 16px;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #00d9a8 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.3);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 168, 132, 0.4);
}

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

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.history-item {
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.history-item.active {
    background: var(--accent-light);
}

.history-item i {
    color: var(--accent-primary);
    font-size: 18px;
}

.history-text {
    flex: 1;
    overflow: hidden;
}

.history-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

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

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.user-profile:hover {
    background: var(--bg-tertiary);
}

.user-profile i {
    font-size: 32px;
    color: var(--accent-primary);
}

.profile-text {
    flex: 1;
}

.profile-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.profile-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 150;
    backdrop-filter: blur(4px);
}

/* Main Container */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-chat);
}

/* Options Menu */
.options-menu {
    position: absolute;
    top: 70px;
    right: 16px;
    width: 320px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--shadow);
    display: none;
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
}

.options-menu.active {
    display: block;
    animation: slideDown 0.3s ease;
}

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

.options-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.options-section:last-child {
    border-bottom: none;
}

.options-section h4 {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding: 0 8px;
    font-weight: 600;
}

.option-item {
    width: 100%;
    padding: 14px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    border-radius: 10px;
    transition: background 0.2s;
    font-size: 15px;
    text-align: left;
    margin-bottom: 4px;
}

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

.option-item i:first-child {
    color: var(--accent-primary);
    width: 20px;
    font-size: 18px;
}

.option-item span {
    flex: 1;
}

.option-item .check-icon {
    color: var(--accent-primary);
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 16px;
}

.option-item.active .check-icon {
    opacity: 1;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    background-color: white;
    transform: translateX(20px);
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.welcome-content {
    text-align: center;
    max-width: 600px;
    width: 100%;
}

.ai-logo {
    font-size: 80px;
    margin-bottom: 24px;
    animation: float 3s ease-in-out infinite;
}

.ai-logo i {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #00d9a8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.welcome-content h1 {
    font-size: 32px;
    margin-bottom: 12px;
    font-weight: 600;
}

.welcome-content p {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 40px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.quick-action-card {
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.quick-action-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow);
}

.quick-action-card i {
    font-size: 28px;
    color: var(--accent-primary);
    margin-bottom: 12px;
    display: block;
}

.quick-action-card span {
    display: block;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: none;
    scroll-behavior: smooth;
}

.chat-messages.active {
    display: block;
}

.message {
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease;
}

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

.message-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.message.user .message-wrapper {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.message-avatar.user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-avatar.ai {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #00d9a8 100%);
    color: white;
}

.message-content {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 15px;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--message-user);
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

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

.message-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
    padding: 0 14px;
    text-align: right;
}

.message.ai .message-time {
    text-align: left;
}

/* WhatsApp-like Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease;
}

.typing-indicator .message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #00d9a8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.typing-dots {
    background: var(--message-ai);
    padding: 14px 18px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Container */
.input-container {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 12px 16px 16px;
}

.active-features {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.feature-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--accent-light);
    border: 1px solid var(--accent-primary);
    border-radius: 16px;
    font-size: 12px;
    color: var(--accent-primary);
    font-weight: 500;
}

.feature-badge i {
    font-size: 11px;
}

.media-preview-area {
    display: none;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.media-preview-area.active {
    display: flex;
}

.media-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-tertiary);
}

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

.media-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-tertiary);
    border-radius: 24px;
    padding: 8px 12px;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    background: var(--bg-primary);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.attach-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    font-size: 20px;
    flex-shrink: 0;
}

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

#messageInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    outline: none;
    max-height: 120px;
    font-family: inherit;
    line-height: 1.5;
    padding: 8px 0;
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

.action-buttons {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.voice-btn,
.send-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 18px;
}

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

.send-btn {
    background: var(--accent-primary);
    color: white;
    display: none;
}

.send-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.send-btn.active {
    display: flex;
}

.voice-btn.hidden {
    display: none;
}

.input-footer {
    text-align: center;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Attach Menu */
.attach-menu {
    position: absolute;
    bottom: 120px;
    left: 16px;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 16px;
    display: none;
    gap: 16px;
    box-shadow: 0 8px 32px var(--shadow);
    z-index: 100;
}

.attach-menu.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

.attach-option {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 12px;
    transition: all 0.2s;
}

.attach-option:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

.attach-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.attach-option span {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Voice Recording Modal */
.voice-recording-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.voice-recording-modal.active {
    display: flex;
}

.voice-modal-content {
    text-align: center;
    padding: 40px;
}

.voice-animation {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 24px;
}

.voice-wave {
    width: 6px;
    background: var(--accent-primary);
    border-radius: 3px;
    animation: wave 1.2s ease-in-out infinite;
}

.voice-wave:nth-child(1) {
    height: 40px;
    animation-delay: 0s;
}

.voice-wave:nth-child(2) {
    height: 60px;
    animation-delay: 0.1s;
}

.voice-wave:nth-child(3) {
    height: 80px;
    animation-delay: 0.2s;
}

.voice-wave:nth-child(4) {
    height: 60px;
    animation-delay: 0.3s;
}

.voice-wave:nth-child(5) {
    height: 40px;
    animation-delay: 0.4s;
}

@keyframes wave {
    0%, 100% {
        transform: scaleY(0.5);
    }
    50% {
        transform: scaleY(1);
    }
}

.voice-timer {
    font-size: 48px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 16px;
    font-variant-numeric: tabular-nums;
}

.voice-modal-content p {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.voice-controls {
    display: flex;
    gap: 24px;
    justify-content: center;
}

.voice-cancel,
.voice-send {
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.voice-cancel {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.voice-cancel:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
}

.voice-send {
    background: var(--accent-primary);
    color: white;
}

.voice-send:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .close-sidebar {
        display: block;
    }

    .options-menu {
        right: 8px;
        width: calc(100vw - 32px);
        max-width: 320px;
        top: 60px;
    }

    .message-content {
        max-width: 85%;
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }

    .welcome-content h1 {
        font-size: 24px;
    }

    .ai-logo {
        font-size: 64px;
    }

    .attach-menu {
        left: 50%;
        transform: translateX(-50%);
        bottom: 140px;
    }

    .attach-menu.active {
        transform: translateX(-50%);
    }
}

@media (max-width: 480px) {
    .input-container {
        padding: 8px 12px 12px;
    }

    .chat-messages {
        padding: 12px;
    }

    .message-content {
        max-width: 90%;
        font-size: 14px;
        padding: 8px 12px;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .voice-modal-content {
        padding: 24px;
    }

    .voice-timer {
        font-size: 36px;
    }

    .voice-controls {
        flex-direction: column;
        width: 100%;
    }

    .voice-cancel,
    .voice-send {
        width: 100%;
        justify-content: center;
    }

    .attach-icon {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .welcome-screen {
        padding: 16px;
    }

    .ai-logo {
        font-size: 48px;
        margin-bottom: 16px;
    }

    .welcome-content h1 {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .welcome-content p {
        margin-bottom: 20px;
    }

    .quick-actions {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .quick-action-card {
        padding: 12px;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .mobile-header,
    .input-container,
    .options-menu,
    .attach-menu,
    .voice-recording-modal {
        display: none !important;
    }

    .main-container {
        background: white;
    }

    .chat-messages {
        display: block !important;
    }

    .message-content {
        border: 1px solid #ddd;
    }
}
