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

:root {
    --primary: #075E54;
    --secondary: #128C7E;
    --accent: #25D366;
    --background: #0a0e27;
    --surface: #151932;
    --surface-light: #1e2442;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%);
    animation: pulse 15s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulse {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(180deg); }
}

.app-container {
    position: relative;
    min-height: 100vh;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
}

.app-container::-webkit-scrollbar {
    width: 6px;
}

.app-container::-webkit-scrollbar-track {
    background: transparent;
}

.app-container::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: auto 0;
}

/* Welcome State */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

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

.logo-container {
    margin-bottom: 1.5rem;
}

.logo {
    width: 70px;
    height: 70px;
    background: var(--gradient);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4);
    animation: float 3s ease-in-out infinite;
}

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

.logo i {
    font-size: 32px;
    color: white;
}

h1 {
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: var(--text-secondary);
    max-width: 550px;
    margin: 0 auto 2rem;
    line-height: 1.5;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.header-content {
    text-align: left;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    width: 100%;
    margin-bottom: 2rem;
}

.feature-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    transition: all 0.3s ease;
}

.feature-item:hover {
    transform: translateY(-3px);
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.2);
}

.feature-icon {
    width: 42px;
    height: 42px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-icon i {
    font-size: 18px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.feature-text {
    text-align: left;
}

.feature-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.feature-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.upload-section {
    width: 100%;
    max-width: 550px;
    margin: 0 auto;
}

.upload-info {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    padding: 0.875rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.upload-info i {
    font-size: 1.3rem;
    color: #667eea;
    flex-shrink: 0;
}

.upload-info-text {
    text-align: left;
    flex: 1;
}

.upload-info-text strong {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.upload-info-text p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.upload-area {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-area:hover {
    border-color: rgba(102, 126, 234, 0.5);
    transform: translateY(-2px);
}

.upload-area:hover::before {
    opacity: 0.05;
}

.upload-area.dragging {
    border-color: var(--accent);
    background: rgba(37, 211, 102, 0.1);
}

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

.upload-icon {
    width: 65px;
    height: 65px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.upload-icon i {
    font-size: 28px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.upload-text {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.upload-subtext {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.875rem;
}

.file-types {
    display: flex;
    gap: 0.625rem;
    justify-content: center;
    flex-wrap: wrap;
}

.file-type-badge {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    padding: 0.4rem 0.875rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.file-type-badge i {
    color: #667eea;
}

.file-name {
    display: none;
    margin: 1.25rem auto 0;
    padding: 0.875rem 1.25rem;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 550px;
    font-size: 0.9rem;
    color: var(--text-primary);
    animation: slideDown 0.3s ease-out;
}

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

.process-btn {
    display: none;
    margin: 0.875rem auto 0;
    padding: 0.875rem 2.25rem;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.process-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

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

.loading {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.875rem;
    margin-top: 1.5rem;
}

.spinner {
    width: 45px;
    height: 45px;
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* Analysis Screen */
.analysis-screen {
    display: none;
    animation: fadeIn 0.6s ease-out;
}

.analysis-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    height: calc(100vh - 3rem);
    max-height: 750px;
}

/* Chat Preview Panel */
.chat-panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.chat-header {
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.back-btn {
    width: 40px;
    height: 40px;
    background: rgba(102, 126, 234, 0.1);
    border: none;
    border-radius: 10px;
    color: #667eea;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateX(-2px);
}

.chat-avatar {
    width: 42px;
    height: 42px;
    background: var(--gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
}

.chat-info h3 {
    font-size: 1.05rem;
    margin-bottom: 0.15rem;
}

.chat-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--background);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

.date-header {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin: 1.25rem 0;
    position: relative;
}

.date-header::before,
.date-header::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}

.date-header::before { left: 0; }
.date-header::after { right: 0; }

.chat-message {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.65rem;
    animation: messageSlide 0.3s ease-out;
}

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

.chat-message.sent {
    align-items: flex-end;
}

.chat-message.received {
    align-items: flex-start;
}

.sender-name {
    font-size: 0.75rem;
    color: #667eea;
    margin-bottom: 0.2rem;
    padding: 0 0.65rem;
    font-weight: 500;
}

.message-bubble {
    max-width: 70%;
    padding: 0.65rem 0.875rem;
    border-radius: 12px;
    position: relative;
}

.sent .message-bubble {
    background: var(--gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

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

.message-text {
    word-wrap: break-word;
    line-height: 1.5;
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    text-align: right;
}

.system-notification {
    text-align: center;
    padding: 0.4rem 0.875rem;
    margin: 0.4rem auto;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    width: fit-content;
    max-width: 80%;
}

/* AI Chat Messages in Chat Preview (Mobile) */
.ai-chat-message {
    display: flex;
    flex-direction: column;
    margin: 0.75rem 0;
    animation: messageSlide 0.3s ease-out;
}

.ai-chat-message.user {
    align-items: flex-end;
}

.ai-chat-message.assistant {
    align-items: flex-start;
}

.ai-chat-bubble {
    max-width: 85%;
    padding: 0.875rem 1rem;
    border-radius: 14px;
    line-height: 1.6;
    font-size: 0.95rem;
    word-wrap: break-word;
}

.ai-chat-message.user .ai-chat-bubble {
    background: var(--gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-chat-message.assistant .ai-chat-bubble {
    background: var(--surface-light);
    border-bottom-left-radius: 4px;
}

/* AI Analysis Panel */
.ai-panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.ai-header {
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex-shrink: 0;
}

.ai-avatar {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
}

.ai-info h3 {
    font-size: 1.05rem;
    margin-bottom: 0.15rem;
}

.ai-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--background);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

.ai-message {
    display: flex;
    flex-direction: column;
    animation: messageSlide 0.3s ease-out;
}

.ai-message.user {
    align-items: flex-end;
}

.ai-message.assistant {
    align-items: flex-start;
}

.ai-message-bubble {
    max-width: 85%;
    padding: 0.875rem 1rem;
    border-radius: 14px;
    line-height: 1.6;
    font-size: 0.95rem;
}

.user .ai-message-bubble {
    background: var(--gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant .ai-message-bubble {
    background: var(--surface-light);
    border-bottom-left-radius: 4px;
}

.ai-welcome {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.ai-welcome-icon {
    width: 80px;
    height: 80px;
    background: rgba(240, 147, 251, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.ai-welcome-icon i {
    font-size: 32px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ai-welcome h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.ai-welcome p {
    font-size: 0.9rem;
    line-height: 1.6;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.suggestion-chip {
    padding: 0.5rem 1rem;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.suggestion-chip:hover {
    background: rgba(240, 147, 251, 0.1);
    border-color: rgba(240, 147, 251, 0.3);
    transform: translateY(-2px);
}

/* Chat Input */
.chat-input-container {
    padding: 1rem 1.25rem;
    background: var(--surface-light);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    overflow-y: auto;
}

.chat-input::-webkit-scrollbar {
    width: 4px;
}

.chat-input::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
}

.chat-input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.5);
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    width: 44px;
    height: 44px;
    background: var(--gradient);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.typing-indicator {
    display: none;
    padding: 0.875rem 1rem;
    background: var(--surface-light);
    border-radius: 14px;
    align-self: flex-start;
    max-width: 80px;
}

.typing-dots {
    display: flex;
    gap: 0.3rem;
}

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

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Desktop Layout */
@media (min-width: 1024px) {
    .analysis-layout {
        grid-template-columns: 1fr 420px;
        gap: 1.5rem;
    }

    .chat-panel .chat-input-container {
        display: none;
    }
    .ai-chat-message {
        display: none;
    }
}

/* Mobile Responsive */
@media (max-width: 1023px) {
    .ai-panel {
        display: none;
    }

    .chat-panel {
        height: 100%;
    }
    .ai-chat-message {
        display: flex;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .logo-container {
        margin-bottom: 0;
    }

    .header-row {
        margin-bottom: 1.25rem;
    }

    .logo {
        width: 55px;
        height: 55px;
        margin: 0;
    }

    .logo i {
        font-size: 24px;
    }

    h1 {
        font-size: 1.625rem;
        margin-bottom: 0.25rem;
    }

    .subtitle {
        font-size: 0.825rem;
        margin-bottom: 0;
        line-height: 1.4;
    }

    .features {
        grid-template-columns: 1fr;
        gap: 0.875rem;
        margin-bottom: 1.5rem;
    }

    .feature-item {
        padding: 1rem;
    }

    .feature-icon {
        width: 38px;
        height: 38px;
    }

    .feature-title {
        font-size: 0.95rem;
    }

    .feature-desc {
        font-size: 0.8rem;
    }

    .upload-info {
        padding: 0.75rem 1rem;
    }

    .upload-info i {
        font-size: 1.15rem;
    }

    .upload-info-text strong {
        font-size: 0.875rem;
    }

    .upload-info-text p {
        font-size: 0.75rem;
    }

    .upload-area {
        padding: 1.5rem 1rem;
    }

    .upload-icon {
        width: 55px;
        height: 55px;
    }

    .upload-icon i {
        font-size: 24px;
    }

    .upload-text {
        font-size: 1rem;
    }

    .upload-subtext {
        font-size: 0.8rem;
    }

    .file-type-badge {
        padding: 0.35rem 0.75rem;
        font-size: 0.75rem;
    }

    .process-btn {
        padding: 0.75rem 1.875rem;
        font-size: 0.95rem;
        width: 100%;
        max-width: 280px;
    }

    .analysis-layout {
        height: calc(100vh - 2rem);
        max-height: none;
    }

    .chat-panel {
        border-radius: 16px;
    }

    .chat-header {
        padding: 0.875rem 1rem;
    }

    .back-btn {
        width: 36px;
        height: 36px;
    }

    .chat-avatar {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .chat-info h3 {
        font-size: 0.95rem;
    }

    .chat-info p {
        font-size: 0.75rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .message-bubble {
        max-width: 82%;
        padding: 0.55rem 0.75rem;
    }

    .message-text {
        font-size: 0.9rem;
    }

    .ai-chat-bubble {
        max-width: 90%;
        padding: 0.75rem 0.875rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0.75rem;
    }

    .logo {
        width: 50px;
        height: 50px;
    }

    .logo i {
        font-size: 22px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.775rem;
    }

    .feature-icon {
        width: 36px;
        height: 36px;
    }

    .feature-icon i {
        font-size: 16px;
    }

    .feature-title {
        font-size: 0.9rem;
    }

    .feature-desc {
        font-size: 0.75rem;
    }
}

@media (max-height: 700px) {
    .app-container {
        padding: 0.75rem;
    }

    .logo-container {
        margin-bottom: 0.75rem;
    }

    .header-row {
        margin-bottom: 0.875rem;
    }

    .subtitle {
        margin-bottom: 1rem;
    }

    .features {
        margin-bottom: 1rem;
    }

    .upload-info {
        margin-bottom: 0.75rem;
        padding: 0.625rem 1rem;
    }

    .upload-area {
        padding: 1.25rem 1rem;
    }

    .upload-icon {
        width: 50px;
        height: 50px;
        margin-bottom: 0.625rem;
    }

    .upload-icon i {
        font-size: 22px;
    }

    .upload-text {
        font-size: 1rem;
        margin-bottom: 0.3rem;
    }

    .upload-subtext {
        font-size: 0.8rem;
        margin-bottom: 0.625rem;
    }

    .feature-item {
        padding: 0.875rem;
    }
}

@media (max-height: 600px) {
    .logo {
        width: 50px;
        height: 50px;
    }

    .logo i {
        font-size: 22px;
    }

    .features {
        gap: 0.75rem;
    }

    .feature-item {
        padding: 0.75rem;
    }

    .feature-icon {
        width: 36px;
        height: 36px;
    }
}