/**
 * vv3B Components CSS
 * Component-specific styling for the chat interface
 */

/* Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-large {
    max-width: 640px;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

/* Form Components */
.form-group {
    margin-bottom: 20px;
}

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

.form-input, .form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder {
    color: var(--text-secondary);
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.button:hover {
    background: var(--bg-primary);
    border-color: var(--text-secondary);
}

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

.button-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.button-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.button-secondary {
    background: transparent;
    border-color: var(--border);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

/* Icon Buttons */
.icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-button:hover {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-primary);
}

.icon-button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Send Button */
.send-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.send-button:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.send-button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.send-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Message Components */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    max-width: 100%;
    flex-shrink: 0; /* Prevent messages from shrinking */
}

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

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

.message-system {
    justify-content: center;
    opacity: 0.7;
}

.message-system .message-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    font-size: 0.85rem;
    text-align: center;
}

.message-sealed .message-content {
    background: linear-gradient(45deg, var(--bg-secondary), var(--border));
    border: 1px solid var(--border);
}

.message-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    min-width: 0;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 12px 16px;
    max-width: 70%;
}

.message-own .message-content {
    border-bottom-right-radius: 6px;
}

.message:not(.message-own) .message-content {
    border-bottom-left-radius: 6px;
}

.message-sender {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.message-text {
    color: var(--text-primary);
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-own .message-text {
    color: white;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

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

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.welcome-message h3 {
    margin: 0 0 12px 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.welcome-message p {
    margin: 8px 0;
    line-height: 1.5;
    max-width: 400px;
}

/* Peer Components */
.peer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.peer-item:hover {
    background: var(--bg-primary);
}

.peer-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.peer-details {
    flex: 1;
    min-width: 0;
}

.peer-alias {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.peer-fingerprint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Status Components */
.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    transition: background-color 0.3s ease;
}

.status-indicator.connecting {
    background: var(--warning);
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: var(--success);
}

.status-indicator.disconnected {
    background: var(--error);
}

.status-indicator.error {
    background: var(--error);
    animation: pulse 1s infinite;
}

.status-indicator.offline {
    background: var(--text-secondary);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.status-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Peer Count Badge */
.peer-count-badge {
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
}

/* Settings Components */
.settings-section {
    margin-bottom: 32px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h3 {
    margin: 0 0 16px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
}

.setting-row label {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0;
}

.setting-row input[type="checkbox"] {
    margin-right: 8px;
}

/* Color Picker */
.color-picker {
    display: flex;
    gap: 8px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.color-option:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.color-option.active {
    border-color: var(--text-primary);
}

/* Key Display */
.key-display, .fingerprint-display {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.fingerprint-display {
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 1px;
}

/* Loading Components */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Room List */
.room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    border: 1px solid transparent;
}

.room-item:hover {
    background: var(--bg-primary);
    border-color: var(--border);
}

.room-item.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.room-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.room-peer-count {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Identity Info */
.identity-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.identity-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}

.identity-details {
    flex: 1;
    min-width: 0;
}

.identity-alias {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.identity-fingerprint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Scrollbars */
.messages-scroll::-webkit-scrollbar,
.peer-list::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.messages-scroll::-webkit-scrollbar-track,
.peer-list::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.messages-scroll::-webkit-scrollbar-thumb,
.peer-list::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.messages-scroll::-webkit-scrollbar-thumb:hover,
.peer-list::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Room Discovery */
.available-rooms {
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.no-rooms {
    text-align: center;
}

.no-rooms p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.suggested-rooms p {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.room-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.room-suggestion {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.room-suggestion:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.room-list-items h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.room-list-items .room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.room-list-items .room-item:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.room-list-items .room-item:last-child {
    margin-bottom: 0;
}

.room-name {
    font-weight: 500;
}

.room-stats {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Help Modal */
.help-section {
    margin-bottom: 24px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.help-section p {
    margin: 0 0 12px 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-section li {
    margin-bottom: 8px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.help-section li:last-child {
    margin-bottom: 0;
}

.help-section strong {
    color: var(--text-primary);
    font-weight: 600;
}