:root {
    --bg-gradient-start: #0a0a0a;
    --bg-gradient-end: #0f0f12;
    --card-bg: rgba(16, 16, 18, 0.7);
    --card-gradient: linear-gradient(145deg, rgba(20, 20, 25, 0.6), rgba(12, 12, 16, 0.8));
    --surface: #151518;
    --surface-light: #202027;
    --primary: #8b5cf6;
    --primary-light: #a78bfa;
    --primary-dark: #7c3aed;
    --primary-gradient: linear-gradient(135deg, #8b5cf6, #6d28d9);
    --secondary: #0ea5e9;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-link: #00aff4;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border-radius: 16px;
    --button-radius: 12px;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
    --scrollbar-bg: rgba(20, 20, 25, 0.6);
    --scrollbar-thumb: rgba(139, 92, 246, 0.4);
    --scrollbar-thumb-hover: rgba(139, 92, 246, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-primary);
    min-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
}

.container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    max-height: 800px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-bg);
}

/* Loading overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

#loading-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Notification */
.notification {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-gradient);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: var(--button-radius);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    transition: top 0.3s ease;
    max-width: 90%;
    text-align: center;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.notification.error {
    border-left: 4px solid var(--danger);
}

.notification.success {
    border-left: 4px solid var(--success);
}

.notification.show {
    top: 20px;
}

/* Notification Permission Dialog */
.permission-content {
    max-width: 360px;
}

.notification-icon {
    width: 70px;
    height: 70px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 20px;
    box-shadow: var(--shadow-md);
}

.notification-icon i {
    font-size: 32px;
    color: white;
}

.permission-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.permission-footer button {
    flex: 1;
}

/* Landing page */
.landing-page {
    background: var(--card-gradient);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    text-align: center;
    border-radius: var(--border-radius);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.logo-container {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-circle {
    width: 80px;
    height: 80px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.logo-circle i {
    font-size: 36px;
    color: white;
}

h1 {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
}

.highlight {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.25rem;
    font-weight: 300;
    margin-bottom: 50px;
}

.options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 50px;
}

.option-btn {
    width: 100%;
    padding: 16px 24px;
    background: rgba(20, 20, 25, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 14px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.option-btn:hover {
    background: rgba(32, 32, 40, 0.6);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.btn-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.btn-icon i {
    color: white;
    font-size: 1.2rem;
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    text-align: center;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-gradient);
    width: 90%;
    max-width: 400px;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalAppear 0.4s forwards;
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.confirm-content {
    max-width: 340px;
}

.confirm-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.confirm-footer button {
    flex: 1;
}

@keyframes modalAppear {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.close-modal:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 30px 24px;
    text-align: center;
}

.modal-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 1rem;
}

.code-display {
    background: rgba(12, 12, 16, 0.5);
    padding: 20px;
    border-radius: var(--button-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#generated-code {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 5px;
    color: var(--primary-light);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.code-input-container {
    margin: 10px 0;
}

#code-input {
    width: 100%;
    padding: 18px 20px;
    background: rgba(12, 12, 16, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 1.8rem;
    text-align: center;
    letter-spacing: 10px;
    transition: var(--transition);
    font-weight: 600;
}

#code-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
}

.modal-footer {
    padding: 20px 24px;
    display: flex;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.primary-btn {
    padding: 14px 28px;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--button-radius);
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.secondary-btn {
    padding: 14px 28px;
    background: rgba(32, 32, 40, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.secondary-btn:hover {
    background: rgba(40, 40, 50, 0.6);
}

.danger-btn {
    padding: 14px 28px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--button-radius);
    color: var(--danger);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Chat container */
.chat-container {
    display: none;
    flex-direction: column;
    height: 100%;
    background: var(--card-gradient);
    border-radius: var(--border-radius);
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.chat-header {
    padding: 16px 20px;
    background: rgba(12, 12, 16, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-info h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.chat-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 4px;
}

#end-chat-btn {
    padding: 10px 18px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--button-radius);
    color: var(--danger);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

#end-chat-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.active-code {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--primary-light);
    background: rgba(139, 92, 246, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    -webkit-overflow-scrolling: touch;
}

.welcome-message {
    align-self: center;
    background: rgba(12, 12, 16, 0.5);
    padding: 14px 20px;
    border-radius: var(--button-radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.welcome-message i {
    color: var(--primary);
}

/* Message container with timestamp */
.message-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 85%;
    animation: messageAppear 0.3s;
    position: relative;
    cursor: pointer;
}

.message-container.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.message-container:hover .message {
    box-shadow: var(--shadow-md);
}

.message-container:active .message {
    opacity: 0.9;
}

@keyframes messageAppear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message {
    padding: 14px 18px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.message-sent {
    background: var(--primary-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-received {
    background: rgba(32, 32, 40, 0.5);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Reply styling */
.message-reply-container {
    margin-bottom: 5px;
    border-radius: 12px 12px 0 0;
    max-width: 100%;
    background: rgba(12, 12, 16, 0.5);
    border-left: 2px solid var(--primary);
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 250px;
}

.message.with-reply {
    margin-top: 0;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

/* Simple message timestamp styling */
.message-timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    margin-right: 4px;
    margin-left: 4px;
    display: inline-block;
}

/* Reply preview area */
.reply-preview {
    display: flex;
    align-items: center;
    background: rgba(32, 32, 40, 0.5);
    padding: 10px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 2px solid var(--primary);
}

.reply-preview.hidden {
    display: none;
}

.reply-preview-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.reply-preview-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cancel-reply-preview {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    cursor: pointer;
}

.cancel-reply-preview:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Message actions menu */
.message-actions {
    position: fixed;
    background: var(--card-gradient);
    border-radius: var(--button-radius);
    padding: 8px;
    box-shadow: var(--shadow-md);
    z-index: 100;
    display: none;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-action-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: var(--button-radius);
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    transition: var(--transition);
}

.message-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.message-action-btn i {
    color: var(--primary-light);
}

/* Typing indicator */
.typing-indicator {
    padding: 8px 15px;
    background: rgba(12, 12, 16, 0.5);
    border-radius: 20px;
    margin: 0 auto 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    align-self: flex-start;
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-left: 24px;
    margin-bottom: 10px;
}

.typing-indicator .dot {
    display: inline-block;
    animation: typingDot 1.4s infinite;
    margin-left: 2px;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0; }
    30% { opacity: 1; }
}

/* Status indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-dot.online {
    background-color: var(--success);
}

.status-dot.idle {
    background-color: var(--warning);
}

.status-dot.away {
    background-color: var(--warning);
}

.status-dot.offline {
    background-color: #6b7280;
}

.input-area {
    padding: 16px;
    background: rgba(12, 12, 16, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.input-container {
    display: flex;
    align-items: center;
    background: rgba(32, 32, 40, 0.5);
    border-radius: 30px;
    padding: 4px 8px 4px 18px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 0;
    color: var(--text-primary);
    font-size: 1rem;
}

#message-input:focus {
    outline: none;
}

#message-input::placeholder {
    color: var(--text-muted);
}

#send-btn {
    width: 42px;
    height: 42px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

#send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.owner-only {
    display: none;
}

/* Swipe animations */
.message {
    position: relative;
    transition: transform 0.2s ease;
}

.message.swiping-right {
    transform: translateX(60px);
}

.message.swiping-left {
    transform: translateX(-60px);
}

/* Message ripple effect for mobile tap */
.ripple {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* Push notification badge */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Responsive styles */
@media (max-width: 600px) {
    body {
        padding: 0;
    }

    .container {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        max-height: none;
        width: 100%;
        border-radius: 0;
    }
    
    .landing-page, .chat-container {
        border-radius: 0;
    }
    
    .modal-content {
        width: 95%;
    }
}

@media (max-height: 700px) {
    .logo-container {
        margin-bottom: 20px;
    }
    
    .logo-circle {
        width: 60px;
        height: 60px;
        margin-bottom: 15px;
    }
    
    .logo-circle i {
        font-size: 28px;
    }
    
    h1 {
        font-size: 2.4rem;
    }
    
    .tagline {
        margin-bottom: 30px;
        font-size: 1.1rem;
    }
    
    .options {
        margin-bottom: 30px;
    }
    
    .option-btn {
        padding: 12px 20px;
    }
    
    .footer-text {
        bottom: 20px;
    }
}

/* PWA status bar style for iOS */
@supports (-webkit-touch-callout: none) {
    .chat-header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }
    
    .container {
        height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        max-height: none;
    }
}