/* ChatEx ASP.NET Client Styles */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f0f2f5;
    height: 100%;
    overflow: hidden;
}

/* Utility */
.hidden { display: none !important; }
.hidden-desktop { display: none; }

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #e9ebee 0%, #d1d5db 100%);
}
.auth-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}
.auth-header { text-align: center; margin-bottom: 32px; }
.logo-circle {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    color: white; font-size: 28px; font-weight: bold;
    box-shadow: 0 4px 12px rgba(34,197,94,0.3);
}
.auth-header h2 { font-size: 24px; color: #1f2937; margin-bottom: 8px; }
.subtitle { color: #6b7280; font-size: 14px; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { width: 100%; }
.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s;
    background: #f9fafb;
}
.form-input:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34,197,94,0.1);
    background: white;
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 24px;
    border: none; border-radius: 10px;
    font-size: 15px; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    gap: 8px;
}
.btn-primary {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    box-shadow: 0 4px 12px rgba(34,197,94,0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(34,197,94,0.4);
}
.btn-block { width: 100%; }
.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-icon {
    background: transparent;
    color: #6b7280;
    padding: 8px;
    border-radius: 50%;
}
.btn-icon:hover { background: #f3f4f6; color: #1f2937; }
.btn-send {
    background: #22c55e;
    color: white;
    padding: 10px;
    border-radius: 50%;
}
.btn-send:hover { background: #16a34a; }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

.auth-footer { text-align: center; margin-top: 24px; font-size: 14px; color: #6b7280; }
.link { color: #22c55e; text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

.loading-spinner {
    width: 20px; height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 8px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Chat App */
.chat-app { display: flex; flex-direction: column; height: 100vh; }

/* Header */
.chat-header-bar {
    background: linear-gradient(135deg, #15803d, #16a34a);
    color: white;
    padding: 12px 20px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
    flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-avatar {
    width: 40px; height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 16px;
}
.header-info h3 { font-size: 16px; font-weight: 600; }
.status-text { font-size: 12px; opacity: 0.85; }

/* Call Overlays */
.call-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    color: white;
}
.call-container { text-align: center; padding: 32px; }
.call-avatar {
    width: 96px; height: 96px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
    font-size: 40px; font-weight: bold;
}
.call-type-text { color: #9ca3af; font-size: 16px; margin-bottom: 32px; }
.call-actions { display: flex; justify-content: center; gap: 32px; }
.call-btn {
    width: 64px; height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: white;
    transition: transform 0.2s;
}
.call-btn:hover { transform: scale(1.05); }
.call-btn-answer { background: linear-gradient(135deg, #22c55e, #16a34a); }
.call-btn-decline { background: linear-gradient(135deg, #ef4444, #dc2626); }
.local-video {
    width: 320px; height: 240px;
    border-radius: 12px;
    background: #1f2937;
    margin-bottom: 16px;
    object-fit: cover;
}

/* Chat Body */
.chat-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #f0f2f5;
}

/* Contact List */
.contact-list {
    width: 320px;
    background: white;
    border-right: 1px solid #e5e7eb;
    display: flex; flex-direction: column;
    flex-shrink: 0;
}
.contact-list-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex; justify-content: space-between; align-items: center;
}
.contact-list-header h3 { font-size: 18px; color: #1f2937; }
.contact-list-header span { font-size: 12px; color: #6b7280; }
.contacts-container { overflow-y: auto; flex: 1; }
.contact-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
    position: relative;
}
.contact-item:hover { background: #f9fafb; }
.contact-item.active {
    background: #f0fdf4;
    border-left: 3px solid #22c55e;
}
.contact-avatar {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #15803d; font-weight: bold; font-size: 18px;
    flex-shrink: 0;
}
.contact-info { flex: 1; min-width: 0; }
.contact-name {
    font-weight: 600; color: #1f2937;
    display: flex; justify-content: space-between; align-items: center;
}
.contact-name h4 { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-time { font-size: 11px; color: #9ca3af; font-weight: 400; }
.contact-email {
    font-size: 12px; color: #6b7280;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 2px;
}
.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    position: absolute;
    bottom: 12px; left: 52px;
    border: 2px solid white;
}
.status-dot.online { background: #22c55e; }
.status-dot.offline { background: #9ca3af; }
.unread-badge {
    position: absolute; top: 8px; right: 16px;
    background: #ef4444; color: white;
    font-size: 11px; font-weight: 600;
    min-width: 20px; height: 20px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 6px;
}

/* Chat Window */
.chat-window {
    flex: 1;
    display: flex; flex-direction: column;
    background: #e5ddd5;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23d1d5db' fill-opacity='0.2' fill-rule='evenodd'/%3E%3C/svg%3E");
}
.chat-window-header {
    background: #f0f2f5;
    padding: 10px 16px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid #e5e7eb;
}
.contact-avatar-small {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #15803d; font-weight: bold; font-size: 15px;
}
.chat-contact-info { flex: 1; }
.chat-contact-info h4 { font-size: 15px; color: #1f2937; }
.chat-actions { display: flex; gap: 4px; }

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 4px;
}
.message-group-date {
    text-align: center;
    margin: 12px 0;
}
.message-group-date span {
    background: #e1f3fb;
    color: #54656f;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.message-bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    animation: messageIn 0.2s ease;
}
@keyframes messageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.message-bubble.sent {
    align-self: flex-end;
    background: #d9fdd3;
    color: #111b21;
    border-bottom-right-radius: 2px;
}
.message-bubble.received {
    align-self: flex-start;
    background: white;
    color: #111b21;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.message-bubble a { color: #027eb5; text-decoration: underline; }
.message-bubble audio { max-width: 260px; height: 36px; }
.message-time {
    font-size: 11px;
    color: #667781;
    margin-top: 4px;
    text-align: right;
    display: flex; align-items: center; justify-content: flex-end; gap: 4px;
}
.message-status { color: #53bdeb; font-size: 12px; }

.message-input-bar {
    background: #f0f2f5;
    padding: 8px 16px;
    display: flex; align-items: center; gap: 8px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    z-index: 10;
}
.message-input-wrapper { flex: 1; }
.message-input {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    background: white;
    outline: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.message-input:focus { box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* Typing Indicator */
.typing-indicator { padding: 4px 16px; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
    width: 8px; height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Empty State */
.empty-state {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
    padding: 40px;
}
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; color: #1f2937; margin-bottom: 8px; }
.empty-state p { color: #6b7280; font-size: 14px; max-width: 300px; }

/* Recording state */
.recording { color: #ef4444 !important; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Responsive */
@media (max-width: 768px) {
    .contact-list {
        width: 100%;
        position: absolute;
        z-index: 5;
        height: calc(100% - 64px);
    }
    .contact-list.hidden-mobile { display: none; }
    .chat-window { 
        width: 100%; 
        height: 100vh;
    }
    .hidden-desktop { display: flex; }
    .local-video { width: 200px; height: 150px; }
    
    /* Ensure bottom bar is visible on mobile */
    .message-input-bar {
        padding: 12px 16px;
        box-shadow: 0 -1px 4px rgba(0,0,0,0.1);
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        background: #f0f2f5;
    }
    
    /* Add padding to bottom of messages container to prevent overlap */
    .messages-container {
        padding-bottom: 80px !important;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }
