/* ============================================
   NexusChat - Modal Styles
   ============================================ */

/* ============================================
   基礎模態框
   ============================================ */

.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal.open {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: var(--surface-overlay);
}

.modal-content {
    position: relative;
    width: 100%;
    max-height: 90vh;
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateY(100%);
    transition: transform var(--transition-normal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal.open .modal-content {
    transform: translateY(0);
}

/* 全螢幕模態框 */
.modal.fullscreen {
    align-items: stretch;
}

.modal.fullscreen .modal-content {
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    transform: translateX(100%);
}

.modal.fullscreen.open .modal-content {
    transform: translateX(0);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2 {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    font-size: 28px;
    line-height: 1;
    color: var(--text-secondary);
}

/* ============================================
   貼圖選擇器
   ============================================ */

.sticker-picker {
    height: 50vh;
    max-height: 400px;
}

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

.sticker-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.sticker-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.sticker-tabs::-webkit-scrollbar {
    display: none;
}

.sticker-tab {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sticker-tab:hover {
    background: var(--bg-hover);
}

.sticker-tab.active {
    background: var(--primary-bg);
}

.sticker-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 16px;
    overflow-y: auto;
}

.sticker-item {
    aspect-ratio: 1;
    padding: 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticker-item:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

.sticker-item:active {
    transform: scale(0.95);
}

.sticker-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ============================================
   新增內容選單
   ============================================ */

.add-content-menu {
    padding: 20px 0;
    padding-bottom: calc(20px + var(--safe-area-bottom));
}

.content-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 0 16px;
}

.content-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.content-option:hover {
    background: var(--bg-hover);
}

.content-option:active {
    transform: scale(0.95);
}

.option-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.option-icon svg {
    width: 24px;
    height: 24px;
}

.option-icon.photo { background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%); }
.option-icon.file { background: linear-gradient(135deg, #2196F3 0%, #42A5F5 100%); }
.option-icon.contact { background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%); }
.option-icon.location { background: linear-gradient(135deg, #F44336 0%, #EF5350 100%); }
.option-icon.schedule { background: linear-gradient(135deg, #FF9800 0%, #FFB74D 100%); }
.option-icon.vote { background: linear-gradient(135deg, #00BCD4 0%, #4DD0E1 100%); }

.content-option span {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================
   設定頁面
   ============================================ */

.settings-page {
    background: var(--bg-secondary);
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.settings-header h2 {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.settings-section {
    background: var(--surface);
    margin-bottom: 16px;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

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

.setting-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.setting-icon svg {
    width: 20px;
    height: 20px;
}

.setting-icon.account { background: var(--primary); }
.setting-icon.privacy { background: #9C27B0; }
.setting-icon.notification { background: #F44336; }
.setting-icon.sound { background: #E91E63; }
.setting-icon.theme { background: #FF9800; }
.setting-icon.font { background: #607D8B; }
.setting-icon.chat { background: #2196F3; }
.setting-icon.backup { background: #00BCD4; }
.setting-icon.help { background: #795548; }
.setting-icon.about { background: #9E9E9E; }

.setting-info {
    flex: 1;
    min-width: 0;
}

.setting-title {
    font-size: 16px;
    display: block;
}

.setting-value {
    font-size: 13px;
    color: var(--text-muted);
}

.setting-arrow {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

/* ============================================
   通話介面
   ============================================ */

.call-screen {
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    text-align: center;
}

.call-background {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 30%, rgba(6, 199, 85, 0.2) 0%, transparent 60%);
}

.call-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
}

.call-avatar {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: 0 0 40px rgba(6, 199, 85, 0.3);
    animation: call-pulse 2s ease-in-out infinite;
}

@keyframes call-pulse {
    0%, 100% {
        box-shadow: 0 0 40px rgba(6, 199, 85, 0.3);
    }
    50% {
        box-shadow: 0 0 60px rgba(6, 199, 85, 0.5);
    }
}

.call-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-name {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.call-status {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
}

.call-timer {
    font-size: 20px;
    font-family: var(--font-mono);
    margin-top: 16px;
}

.call-actions {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 32px;
    padding-bottom: calc(32px + var(--safe-area-bottom));
}

.call-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: white;
}

.call-action svg {
    width: 28px;
    height: 28px;
}

.call-action span {
    font-size: 12px;
    opacity: 0.8;
}

.call-action.mute,
.call-action.speaker {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
    justify-content: center;
    padding: 0;
}

.call-action.mute span,
.call-action.speaker span {
    display: none;
}

.call-action.mute:hover,
.call-action.speaker:hover {
    background: rgba(255, 255, 255, 0.25);
}

.call-action.mute.active,
.call-action.speaker.active {
    background: white;
    color: var(--text-primary);
}

.call-action.end {
    width: 70px;
    height: 70px;
    background: var(--error);
    border-radius: var(--radius-full);
    justify-content: center;
    padding: 0;
}

.call-action.end span {
    display: none;
}

.call-action.end:hover {
    background: #d32f2f;
}

/* ============================================
   新增好友
   ============================================ */

.add-friend-page {
    max-height: 80vh;
}

.add-friend-content {
    padding: 24px 16px;
    padding-bottom: calc(24px + var(--safe-area-bottom));
}

.qr-section {
    text-align: center;
    margin-bottom: 32px;
}

.my-qr-code {
    width: 180px;
    height: 180px;
    margin: 0 auto 16px;
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-md);
}

.qr-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.qr-placeholder svg {
    width: 60px;
    height: 60px;
    color: var(--text-muted);
}

.qr-hint {
    font-size: 14px;
    color: var(--text-secondary);
}

.add-methods {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.add-method {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.add-method:hover {
    background: var(--bg-tertiary);
}

.add-method:active {
    transform: scale(0.98);
}

.method-icon {
    width: 44px;
    height: 44px;
    background: var(--primary-bg);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.method-icon svg {
    width: 22px;
    height: 22px;
}

.add-method span {
    font-size: 16px;
    font-weight: 500;
}

/* ============================================
   發佈貼文
   ============================================ */

.post-editor {
    background: var(--surface);
}

.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.post-header h2 {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
}

.btn-post {
    padding: 8px 20px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    font-size: 15px;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.btn-post:hover {
    background: var(--primary-dark);
}

.btn-post:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.post-editor-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.post-author {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.post-author img {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.post-visibility {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.post-visibility span {
    font-weight: 600;
}

.post-visibility select {
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.post-textarea {
    flex: 1;
    padding: 0 16px;
    font-size: 18px;
    line-height: 1.6;
    resize: none;
    min-height: 150px;
}

.post-textarea::placeholder {
    color: var(--text-muted);
}

.post-attachments {
    padding: 16px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.post-attachment {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
}

.post-attachment img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-attachment {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.post-toolbar {
    display: flex;
    border-top: 1px solid var(--border);
    padding: 8px;
    padding-bottom: calc(8px + var(--safe-area-bottom));
}

.post-tool {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.post-tool:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.post-tool svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   圖片預覽
   ============================================ */

.image-viewer {
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.95);
}

.image-viewer .modal-content {
    max-height: 100%;
    height: 100%;
    background: transparent;
    transform: scale(0.9);
    opacity: 0;
}

.image-viewer.open .modal-content {
    transform: scale(1);
    opacity: 1;
}

.viewer-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    padding-top: calc(16px + var(--safe-area-top));
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
    color: white;
    z-index: 10;
}

.viewer-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-close svg {
    width: 24px;
    height: 24px;
}

.viewer-image {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.viewer-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.viewer-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 24px;
    padding-bottom: calc(24px + var(--safe-area-bottom));
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
}

.viewer-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: white;
}

.viewer-action svg {
    width: 24px;
    height: 24px;
}

.viewer-action span {
    font-size: 12px;
    opacity: 0.8;
}

/* ============================================
   確認對話框
   ============================================ */

.confirm-dialog {
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.confirm-dialog .modal-content {
    max-width: 320px;
    border-radius: var(--radius-xl);
    padding: 24px;
    text-align: center;
    transform: scale(0.9);
}

.confirm-dialog.open .modal-content {
    transform: scale(1);
}

.confirm-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-icon.warning {
    background: #FFF3E0;
    color: var(--warning);
}

.confirm-icon.danger {
    background: #FFEBEE;
    color: var(--error);
}

.confirm-icon svg {
    width: 32px;
    height: 32px;
}

.confirm-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.confirm-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
}

.confirm-btn {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.confirm-btn.cancel {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.confirm-btn.cancel:hover {
    background: var(--bg-tertiary);
}

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

.confirm-btn.confirm:hover {
    background: var(--primary-dark);
}

.confirm-btn.danger {
    background: var(--error);
    color: white;
}

.confirm-btn.danger:hover {
    background: #d32f2f;
}
