/* ==========================================================================
   do-chatshare | Apple-style Glassmorphism & WCAG 2.1 AA Design Tokens
   ========================================================================== */

:root {
    --bg-main: #F5F5F7;
    --bg-card: rgba(255, 255, 255, 0.82);
    --bg-card-hover: rgba(255, 255, 255, 0.94);
    --bg-input: rgba(255, 255, 255, 0.9);
    --bg-modal: rgba(255, 255, 255, 0.92);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-focus: #0071E3;
    
    --text-primary: #1D1D1F;
    --text-secondary: #515154;
    --text-muted: #86868B;
    --text-on-primary: #FFFFFF;
    
    --accent-primary: #0071E3;
    --accent-primary-hover: #0077ED;
    --accent-danger: #FF3B30;
    --accent-success: #34C759;
    
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.12);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.mono-num {
    font-family: var(--font-mono);
    font-weight: 600;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none !important;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Buttons & Interactive Controls */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn:focus-visible,
input:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

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

.btn-primary:hover {
    background-color: var(--accent-primary-hover);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.25);
}

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

.btn-outline:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.btn-danger-hover:hover {
    background-color: rgba(255, 59, 48, 0.1);
    color: var(--accent-danger);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-large {
    padding: 14px 24px;
    font-size: 16px;
    width: 100%;
}

.btn-toggle {
    background-color: transparent;
    border-color: transparent;
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
}

.btn-toggle.active {
    background-color: var(--text-primary);
    color: var(--text-on-primary);
}

/* Modal Overlay & Card (Intro Screen) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(29, 29, 31, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-modal);
    padding: 36px 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.brand-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.input-group input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--text-primary);
}

.error-text {
    display: block;
    color: var(--accent-danger);
    font-size: 12px;
    margin-top: 6px;
    min-height: 18px;
}

/* App Header */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 16px;
    gap: 16px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    flex-shrink: 0;
}

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

.logo-dot {
    width: 12px;
    height: 12px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 113, 227, 0.4);
}

.app-logo-small {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
    object-fit: cover;
}

.app-logo-large {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 113, 227, 0.3);
    object-fit: cover;
    margin-bottom: 14px;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-tagline {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 4px;
}

@media (max-width: 768px) {
    .header-tagline {
        display: none;
    }
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-pill,
.user-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.04);
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 13px;
    color: var(--text-secondary);
    border: none;
}

button.status-pill {
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

button.status-pill:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
}

button.status-pill:active {
    transform: scale(0.98);
}

.status-indicator.online {
    width: 8px;
    height: 8px;
    background-color: var(--accent-success);
    border-radius: 50%;
}

/* Online Users Popover */
.online-popover {
    position: absolute;
    top: 72px;
    right: 20px;
    width: 340px;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    padding: 16px;
    box-shadow: var(--shadow-lg);
}

.popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
    font-size: 14px;
}

.online-users-list {
    list-style: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 340px;
}

.online-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-sm);
    gap: 12px;
}

.online-user-name {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.online-user-time {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.view-toggle-bar {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px;
    border-radius: var(--radius-md);
    align-self: center;
    flex-shrink: 0;
}

/* Workspace Grid */
.workspace-grid {
    display: grid;
    flex: 1;
    gap: 16px;
    min-height: 0;
}

.workspace-grid.split-view {
    grid-template-columns: 1fr 1.3fr;
}

.workspace-grid.chat-only {
    grid-template-columns: 1fr;
}

.workspace-grid.paste-only {
    grid-template-columns: 1fr;
}

/* Feature Panels */
.feature-panel {
    display: flex;
    flex-direction: column;
    padding: 20px;
    min-height: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.panel-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.badge {
    background-color: rgba(0, 113, 227, 0.1);
    color: var(--accent-primary);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 100px;
    text-transform: uppercase;
}

.status-subtext {
    font-size: 12px;
    color: var(--text-muted);
}

/* Chat Messages Section */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 6px;
    margin-bottom: 14px;
}

.chat-bubble {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.04);
    align-self: flex-start;
    animation: fadeIn 0.15s ease-out;
}

.chat-bubble.own-message {
    background: var(--accent-primary);
    color: var(--text-on-primary);
    align-self: flex-end;
}

.bubble-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    font-size: 12px;
}

.bubble-sender {
    font-weight: 700;
}

.chat-bubble.own-message .bubble-header {
    color: rgba(255, 255, 255, 0.85);
}

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

.chat-bubble.own-message .bubble-time {
    color: rgba(255, 255, 255, 0.75);
}

.bubble-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 1px 6px;
    border-radius: 4px;
    line-height: 1.2;
    opacity: 0.6;
    margin-left: 6px;
    transition: opacity 0.2s, color 0.2s, background-color 0.2s;
}

.bubble-delete-btn:hover {
    opacity: 1;
    color: var(--accent-danger);
    background-color: rgba(255, 59, 48, 0.15);
}

.chat-bubble.own-message .bubble-delete-btn {
    color: rgba(255, 255, 255, 0.85);
}

.chat-bubble.own-message .bubble-delete-btn:hover {
    color: #FFFFFF;
    background-color: rgba(255, 255, 255, 0.25);
}

.bubble-text {
    font-size: 14px;
    word-break: break-word;
    white-space: pre-wrap;
}

.system-notice {
    align-self: center;
    font-size: 12px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.03);
    padding: 4px 12px;
    border-radius: 100px;
    margin: 4px 0;
}

.chat-input-bar {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.chat-input-bar input {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    font-family: var(--font-sans);
    font-size: 14px;
}

/* Collaborative Pasteboard Section */
.paste-actions,
.chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.paste-meta-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.paste-editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.pasteboard-textarea {
    flex: 1;
    width: 100%;
    resize: none;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    min-height: 200px;
}

/* Shared File Exchange Box */
.attachment-box {
    margin-top: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.attachment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.attachment-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.attachment-title {
    font-weight: 700;
}

.upload-btn-label {
    cursor: pointer;
    background-color: var(--bg-card);
}

.upload-btn-label:hover {
    background-color: var(--bg-card-hover);
}

.attachment-status-area {
    font-size: 13px;
    color: var(--text-secondary);
}

.no-attachment-text {
    font-style: italic;
    color: var(--text-muted);
}

.attachment-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    gap: 12px;
}

.attachment-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.attachment-filename {
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-submeta {
    font-size: 11px;
    color: var(--text-muted);
}

.attachment-actions-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

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

/* Responsive Design */
@media (max-width: 1024px) {
    .view-toggle-bar {
        display: flex;
    }
    
    .workspace-grid.split-view {
        grid-template-columns: 1fr;
    }
    
    .workspace-grid.chat-only #paste-section {
        display: none;
    }
    
    .workspace-grid.paste-only #chat-section {
        display: none;
    }
}
