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

:root {
    --primary: #0077B6;
    --primary-dark: #005F8A;
    --primary-light: #00A8E8;
    --secondary: #48CAE4;
    --accent: #00B4D8;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --white: #FFFFFF;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;
    --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);
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-100);
    min-height: 100vh;
    color: var(--gray-800);
}

.app-container {
    max-width: 100%;
    min-height: 100vh;
    background: var(--white);
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--white);
    color: var(--primary);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
}

.logo i {
    font-size: 1.75rem;
    color: var(--primary);
}

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

.main-content {
    flex: 1;
    padding: 24px 16px;
    padding-bottom: 100px;
    background: linear-gradient(180deg, var(--gray-50) 0%, var(--white) 100%);
}

.welcome-section {
    text-align: center;
    margin-bottom: 28px;
    padding: 28px 24px;
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-100);
}

.welcome-section h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 12px;
}

.welcome-section p {
    color: var(--gray-500);
    font-size: 0.95rem;
    line-height: 1.6;
}

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

.dept-card {
    background: var(--white);
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dept-card:hover, .dept-card:active {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.dept-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    color: var(--white);
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
}

.dept-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--gray-800);
}

.dept-card p {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.app-footer {
    background: var(--gray-800);
    color: var(--gray-400);
    padding: 16px 20px;
    text-align: center;
    font-size: 0.8rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
}

.app-footer i {
    margin-right: 6px;
    color: var(--warning);
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--gray-50);
}

.chat-header {
    background: var(--white);
    color: var(--gray-800);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.back-btn {
    color: var(--primary);
    text-decoration: none;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    width: 40px;
    height: 40px;
    justify-content: center;
    border-radius: 12px;
    transition: background 0.2s;
}

.back-btn:hover {
    background: var(--gray-100);
}

.doctor-info {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}

.doctor-avatar {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    box-shadow: var(--shadow);
}

.doctor-details h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 2px;
}

.doctor-details p {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.online-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--success);
    margin-top: 2px;
}

.online-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.9); }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--gray-50);
}

.message {
    max-width: 88%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 0.9rem;
    line-height: 1.6;
    position: relative;
    animation: slideIn 0.3s ease;
}

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

.message.doctor {
    background: var(--white);
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.message.patient {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    box-shadow: var(--shadow-md);
}

.message-time {
    display: block;
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 8px;
    text-align: right;
}

.message.patient .message-time {
    opacity: 0.8;
}

.message-image {
    max-width: 100%;
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 16px 20px;
    background: var(--white);
    border-radius: 20px;
    align-self: flex-start;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-6px); opacity: 1; }
}

.chat-input-area {
    background: var(--white);
    padding: 16px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.05);
}

.chat-input-area textarea {
    flex: 1;
    border: 2px solid var(--gray-200);
    border-radius: 24px;
    padding: 14px 20px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    background: var(--gray-50);
}

.chat-input-area textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.1);
    background: var(--white);
}

.input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.attach-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-600);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.attach-btn:hover {
    background: var(--gray-200);
    color: var(--primary);
}

.send-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: var(--white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-md);
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

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

.physical-exam-card {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    border: 1px solid #F59E0B;
    border-radius: 16px;
    padding: 18px;
    margin: 12px 0;
}

.physical-exam-card h4 {
    color: #B45309;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
}

.physical-exam-card ol {
    margin-left: 20px;
    color: var(--gray-700);
}

.physical-exam-card li {
    margin-bottom: 8px;
}

.warning-card {
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
    border: 1px solid var(--danger);
    border-radius: 16px;
    padding: 18px;
    margin: 12px 0;
}

.warning-card h4 {
    color: #B91C1C;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
}

.new-session-btn {
    background: var(--gray-100);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.new-session-btn:hover {
    background: var(--gray-200);
    color: var(--primary);
}

.image-preview-container {
    background: var(--gray-100);
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    display: none;
}

.image-preview-container.active {
    display: flex;
    align-items: center;
    gap: 12px;
}

.image-preview {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid var(--gray-300);
}

.remove-image-btn {
    background: var(--danger);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.image-preview-text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--gray-600);
}

@media (min-width: 768px) {
    .app-container {
        max-width: 480px;
        margin: 0 auto;
        box-shadow: var(--shadow-lg);
        border-left: 1px solid var(--gray-200);
        border-right: 1px solid var(--gray-200);
    }
    
    .departments-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .welcome-section {
        padding: 36px 32px;
    }
}

@media (max-width: 380px) {
    .dept-icon {
        width: 56px;
        height: 56px;
        font-size: 1.3rem;
    }
    
    .dept-card h3 {
        font-size: 0.88rem;
    }
    
    .welcome-section h1 {
        font-size: 1.5rem;
    }
    
    .chat-input-area {
        padding: 12px;
    }
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--gray-100);
    color: var(--gray-700);
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.header-btn:hover {
    background: var(--gray-200);
}

.token-badge {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.token-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
    padding: 12px 20px;
    background: var(--gray-50);
    border-radius: 12px;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.token-info i {
    color: var(--warning);
}

.buy-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.buy-link:hover {
    text-decoration: underline;
}

.guest-info {
    margin-top: 16px;
    color: var(--gray-500);
}

.guest-info a {
    color: var(--primary);
    font-weight: 600;
}

.dept-card.featured {
    position: relative;
    border: 2px solid var(--success);
    grid-column: 1 / -1;
}

.featured-badge {
    position: absolute;
    top: -10px;
    right: 16px;
    background: var(--success);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.history-section {
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-section h2 {
    font-size: 1.1rem;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-all-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.auth-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-card {
    background: var(--white);
    border-radius: 20px;
    padding: 32px 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-header i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 16px;
}

.auth-header h1 {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form label {
    display: block;
    margin-bottom: 8px;
    color: var(--gray-700);
    font-weight: 500;
    font-size: 0.9rem;
}

.auth-form label i {
    margin-right: 8px;
    color: var(--gray-400);
}

.auth-form input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-links {
    text-align: center;
    margin-top: 24px;
    color: var(--gray-500);
    font-size: 0.9rem;
}

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

.auth-links span {
    margin: 0 8px;
}

.alert {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.alert-error {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #d1fae5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.alert i {
    font-size: 1.1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-block {
    width: 100%;
}

.profile-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 20px;
    padding: 32px 24px;
    text-align: center;
    color: white;
    margin-bottom: 24px;
}

.profile-avatar {
    font-size: 4rem;
    margin-bottom: 12px;
}

.profile-card h2 {
    font-size: 1.4rem;
    margin-bottom: 6px;
}

.profile-email {
    opacity: 0.9;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.profile-badge {
    display: inline-block;
    padding: 6px 16px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    font-size: 0.85rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: 16px;
    padding: 20px 12px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card i {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.profile-info {
    background: var(--white);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.profile-info h3 {
    font-size: 1rem;
    color: var(--gray-700);
    margin-bottom: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
}

.info-row:last-child {
    border-bottom: none;
}

.packages-grid {
    display: grid;
    gap: 16px;
}

.package-card {
    background: var(--white);
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    border: 2px solid transparent;
}

.package-card.featured {
    border-color: var(--primary);
}

.package-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.package-card h3 {
    font-size: 1.2rem;
    color: var(--gray-800);
    margin-bottom: 12px;
}

.package-price {
    margin-bottom: 12px;
}

.package-price .currency {
    font-size: 1.2rem;
    vertical-align: top;
    color: var(--gray-600);
}

.package-price .amount {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.package-price .period {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.package-tokens {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-100);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
}

.package-desc {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.package-features {
    list-style: none;
    text-align: left;
    margin-bottom: 20px;
}

.package-features li {
    padding: 8px 0;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 10px;
}

.package-features i {
    color: var(--success);
}

.payment-info {
    text-align: center;
    margin-top: 24px;
    color: var(--gray-500);
    font-size: 0.85rem;
}

.payment-info i {
    color: var(--success);
    margin-right: 8px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 4rem;
    color: var(--gray-300);
    margin-bottom: 20px;
}

.empty-state h2 {
    color: var(--gray-600);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 24px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--white);
    padding: 16px;
    border-radius: 16px;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.history-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.history-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
}

.history-content {
    flex: 1;
}

.history-content h4 {
    color: var(--gray-800);
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.history-content p {
    color: var(--gray-500);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.history-date {
    color: var(--gray-400);
    font-size: 0.75rem;
}

.history-item > i {
    color: var(--gray-300);
}

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 1.2rem;
    margin-right: 16px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sessions-bar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.session-toggle {
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sessions-list {
    display: none;
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid var(--gray-100);
}

.sessions-list.show {
    display: block;
}

.session-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.85rem;
}

.session-item:hover {
    background: var(--gray-50);
}

.session-item.active {
    background: var(--primary-light);
    color: white;
}

.session-item small {
    color: var(--gray-400);
}

.session-item.active small {
    color: rgba(255,255,255,0.8);
}

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

.token-count {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--gray-100);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
}

.token-count i {
    color: var(--warning);
}
