/* ChatLink Frontend Styles */
:root {
    --color-primary: #33808d;
    --color-primary-dark: #2a6b75;
    --color-accent: #32b8c5;
    --color-background: #fcfcf9;
    --color-surface: #ffffff;
    --color-text: #1f2121;
    --color-text-light: #6b7280;
    --color-text-white: #ffffff;
    --color-border: #e5e7eb;
    --color-success: #10b981;
    --color-error: #ef4444;
    --color-warning: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Loading Screen */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-background);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 16px;
    color: var(--color-text-light);
    font-size: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* App Container */
.app-container {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Welcome Screen */
.welcome-screen {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 48px 32px;
    max-width: 400px;
    width: 100%;
    margin: 20px;
    text-align: center;
}

.welcome-header {
    margin-bottom: 32px;
}

.welcome-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.welcome-header p {
    color: var(--color-text-light);
    font-size: 16px;
}

.welcome-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.divider {
    position: relative;
    margin: 24px 0;
    color: var(--color-text-light);
    font-size: 14px;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--color-border);
    z-index: 1;
}

.divider span {
    background: var(--color-surface);
    padding: 0 16px;
    position: relative;
    z-index: 2;
}

.invite-join {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    min-height: 44px;
}

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

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text-white);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--color-text-light);
    color: var(--color-text-white);
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}

.btn-outline:hover {
    background: var(--color-primary);
    color: var(--color-text-white);
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
    flex: 1;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    padding: 12px;
    min-width: 44px;
    border-radius: 50%;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-light);
    padding: 4px;
    line-height: 1;
}

/* Forms */
.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    background: var(--color-surface);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(51, 128, 141, 0.1);
}

.form-group {
    margin-bottom: 16px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 100%;
    margin: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: between;
    padding: 24px 24px 0;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    flex: 1;
}

.modal-body {
    padding: 24px;
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    color: var(--color-text-light);
    font-size: 14px;
}

/* Chat Screen */
.chat-screen {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--color-primary);
    color: var(--color-text-white);
    box-shadow: var(--shadow-sm);
}

.chat-info h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 2px;
}

.user-count {
    font-size: 12px;
    opacity: 0.8;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.chat-actions .btn {
    color: var(--color-text-white);
    border-color: rgba(255, 255, 255, 0.3);
}

.chat-actions .btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    padding: 32px 16px;
    margin-bottom: 16px;
}

.welcome-message-content {
    background: var(--color-surface);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    max-width: 400px;
    margin: 0 auto;
}

.welcome-message h4 {
    color: var(--color-primary);
    margin-bottom: 8px;
}

.message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.message.own {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-text-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.message-content {
    max-width: 70%;
    background: var(--color-surface);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.message.own .message-content {
    background: var(--color-primary);
    color: var(--color-text-white);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-author {
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text-light);
}

.message.own .message-author {
    color: rgba(255, 255, 255, 0.8);
}

.message-time {
    font-size: 11px;
    color: var(--color-text-light);
}

.message.own .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message-text {
    word-wrap: break-word;
    line-height: 1.4;
}

.message-file {
    margin-top: 8px;
}

.file-preview {
    max-width: 200px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.file-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
}

.file-icon {
    font-size: 24px;
}

.file-details {
    flex: 1;
}

.file-name {
    font-weight: 500;
    font-size: 14px;
}

.file-size {
    font-size: 12px;
    opacity: 0.8;
}

/* Typing Indicator */
.typing-indicator {
    padding: 8px 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

#typing-text {
    font-size: 12px;
    color: var(--color-text-light);
}

/* Message Input */
.message-input-container {
    padding: 16px 24px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.message-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border-radius: var(--border-radius);
    padding: 4px;
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    outline: none;
}

.file-input {
    display: none;
}

/* Room Selection */
.room-selection {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.room-content {
    background: var(--color-surface);
    padding: 48px 32px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 100%;
    text-align: center;
    margin: 20px;
}

.room-content h2 {
    color: var(--color-primary);
    margin-bottom: 32px;
    font-size: 28px;
}

.room-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.join-room {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Share Modal */
.share-info {
    text-align: center;
}

.invite-code-display {
    display: flex;
    gap: 8px;
    margin: 16px 0;
    align-items: center;
}

.invite-code-display input {
    flex: 1;
    font-family: monospace;
    font-size: 16px;
    text-align: center;
    font-weight: 600;
}

.share-url {
    margin-top: 24px;
    font-size: 14px;
    color: var(--color-text-light);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--color-surface);
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--color-success);
    max-width: 300px;
    opacity: 0;
    transform: translateX(100%);
    transition: var(--transition);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.error {
    border-left-color: var(--color-error);
}

.toast.warning {
    border-left-color: var(--color-warning);
}

/* Responsive Design */
@media (max-width: 768px) {
    .welcome-screen {
        margin: 10px;
        padding: 32px 24px;
    }

    .welcome-actions {
        flex-direction: column;
    }

    .invite-join {
        flex-direction: column;
    }

    .modal-content {
        margin: 10px;
    }

    .chat-header {
        padding: 12px 16px;
    }

    .chat-actions {
        display: none;
    }

    .messages-container {
        padding: 12px;
    }

    .message-content {
        max-width: 85%;
    }

    .message-input-container {
        padding: 12px 16px;
    }

    .room-content {
        margin: 10px;
        padding: 32px 24px;
    }

    .join-room {
        flex-direction: column;
    }

    .invite-code-display {
        flex-direction: column;
    }

    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .welcome-header h1 {
        font-size: 24px;
    }

    .room-content h2 {
        font-size: 22px;
    }

    .btn-lg {
        padding: 12px 24px;
        font-size: 14px;
    }
}

/* Scrollbar Styling */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

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

.messages-container::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-light);
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: slideUp 0.3s ease-out;
}
