* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --accent: #ec4899;
    --success: #10b981;
    --danger: #ef4444;
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--card-bg);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    position: relative;
    overflow-x: hidden;
}

.background-animation {
    display: none;
}

.background-animation::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
    top: -250px;
    right: -250px;
    animation: float 20s ease-in-out infinite;
}

.background-animation::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    border-radius: 50%;
    bottom: -200px;
    left: -200px;
    animation: float 15s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, 30px) scale(1.1); }
}

.container {
    background: var(--card-bg);
    min-height: 100vh;
    width: 100%;
    padding: 25px;
    position: relative;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 2.5em;
    animation: gentle-pulse 3s ease-in-out infinite;
}

@keyframes gentle-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

h1 {
    font-size: 2.75em;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.05em;
    font-weight: 400;
    line-height: 1.6;
}

.status-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 16px;
    margin-bottom: 30px;
    border: 1px solid rgba(99, 102, 241, 0.1);
    transition: all 0.3s ease;
}

.status-card.processing {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: rgba(245, 158, 11, 0.2);
}

.status-card.listening {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: rgba(239, 68, 68, 0.2);
}

.status-icon {
    font-size: 1.2em;
}

.status-text {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1em;
}

.voice-controls {
    text-align: center;
    margin-bottom: 25px;
    position: relative;
    flex-shrink: 0;
}

.record-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 50%;
    width: 140px;
    height: 140px;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.record-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.record-btn:hover::before {
    width: 200px;
    height: 200px;
}

.record-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.5);
}

.record-btn:active {
    transform: translateY(-2px) scale(0.98);
}

.record-btn.recording {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.5);
    animation: recording-pulse 2s ease-in-out infinite;
}

@keyframes recording-pulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 10px 25px rgba(239, 68, 68, 0.5);
    }
    50% { 
        transform: scale(1.08);
        box-shadow: 0 15px 40px rgba(239, 68, 68, 0.7);
    }
}

.mic-wrapper {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-icon {
    width: 48px;
    height: 48px;
    stroke: currentColor;
    stroke-width: 2;
    transition: transform 0.3s;
}

.record-btn:hover .mic-icon {
    transform: scale(1.1);
}

.btn-text {
    font-size: 0.95em;
    font-weight: 600;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}

.recording-indicator {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--danger);
    font-weight: 600;
    font-size: 1em;
    position: relative;
}

.pulse-ring {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid var(--danger);
    border-radius: 50%;
    animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.pulse-dot {
    width: 12px;
    height: 12px;
    background: var(--danger);
    border-radius: 50%;
    position: relative;
    z-index: 1;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes pulse-dot {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.6;
        transform: scale(1.2);
    }
}

.conversation-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    min-height: 0;
}

.conversation-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 4px;
}

.conversation-header span {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.conversation {
    flex: 1;
    min-height: 300px;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: messageSlideIn 0.3s ease-out;
    max-width: 85%;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    flex-shrink: 0;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
}

.user-message .message-avatar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.message-content {
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 0.95em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bot-message .message-content {
    background: white;
    color: var(--text-primary);
    border-top-left-radius: 4px;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-top-right-radius: 4px;
}

.message-content p {
    margin: 0;
}

.session-info {
    text-align: center;
    flex-shrink: 0;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.session-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f9fafb;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.session-label {
    font-size: 0.85em;
    color: var(--text-secondary);
    font-weight: 500;
}

.session-id {
    font-size: 0.85em;
    color: var(--primary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Scrollbar styling */
.conversation::-webkit-scrollbar {
    width: 8px;
}

.conversation::-webkit-scrollbar-track {
    background: transparent;
}

.conversation::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 10px;
}

.conversation::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Medication Section */
.medication-section {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.medication-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.medication-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: var(--text-primary);
    font-weight: 600;
}

.upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.upload-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 14px 18px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.5em;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.upload-text {
    margin: 0;
    font-size: 0.9em;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 500;
}

.upload-btn:active {
    transform: translateY(0);
}

.medication-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px 0;
}

.medication-list::-webkit-scrollbar {
    width: 6px;
}

.medication-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.medication-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.medication-item {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--primary);
    transition: all 0.3s ease;
}

.medication-item:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateX(4px);
}

.medication-item:last-child {
    margin-bottom: 0;
}

.medication-name {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.medication-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.medication-detail {
    display: flex;
    align-items: center;
    gap: 6px;
}

.medication-detail strong {
    color: var(--text-primary);
    font-weight: 500;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-style: italic;
}

.uploading {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-style: italic;
}

.uploading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }
    
    header {
        margin-bottom: 20px;
        padding-bottom: 15px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .record-btn {
        width: 110px;
        height: 110px;
    }
    
    .conversation {
        min-height: 250px;
    }
    
    .status-card {
        padding: 12px 18px;
        margin-bottom: 20px;
    }
    
    .medication-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .upload-section {
        margin-bottom: 20px;
    }
    
    .upload-btn {
        width: 60px;
        height: 60px;
    }
    
    .upload-text {
        font-size: 0.85em;
    }
    
    .medication-details {
        grid-template-columns: 1fr;
    }
}
