/* 
  語音質檢與處理系統 - 設計系統
  風格：Glassmorphism / Neon Cyber Premium
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Noto+Sans+TC:wght@300;400;500;700&display=swap');

:root {
    /* 深色模式變數 */
    --bg-gradient: radial-gradient(circle at 10% 20%, rgba(14, 20, 36, 1) 0%, rgba(20, 27, 49, 1) 90.1%);
    --bg-card: rgba(25, 34, 59, 0.45);
    --bg-input: rgba(12, 18, 33, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(0, 242, 254, 0.35);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* 品牌語意配色 */
    --color-primary: #00f2fe; /* 霓虹青 */
    --color-primary-rgb: 0, 242, 254;
    --color-success: #10b981; /* 翠綠 */
    --color-warning: #f59e0b; /* 橘 */
    --color-danger: #ef4444; /* 紅 */
    --color-purple: #a855f7; /* 紫 */
    
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-glow: 0 0 15px rgba(0, 242, 254, 0.25);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 淺色模式覆蓋 */
[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-input: rgba(241, 245, 249, 0.9);
    --border-color: rgba(15, 23, 42, 0.08);
    --border-hover: rgba(0, 242, 254, 0.6);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow-premium: 0 8px 32px 0 rgba(148, 163, 184, 0.15);
}

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

body {
    font-family: 'Outfit', 'Noto Sans TC', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.6;
    transition: background 0.5s ease, color 0.3s ease;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition-smooth);
}

a:hover {
    text-shadow: 0 0 8px rgba(var(--color-primary-rgb), 0.5);
}

button, input, select, textarea {
    font-family: inherit;
}

/* 捲軸美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 玻璃擬態卡片 */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-premium);
    transition: var(--transition-smooth);
}

.glass-card.hoverable:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-premium), 0 10px 20px rgba(0, 242, 254, 0.05);
}

/* 全域 Layout */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

header {
    background: rgba(12, 18, 33, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-purple));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0c1221;
    font-weight: 700;
    box-shadow: var(--shadow-glow);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-item {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.user-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50px;
    background: var(--color-primary);
    color: #0c1221;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
}

/* 主畫面佈局 */
main {
    flex: 1;
    padding: 32px 0;
}

/* 登入畫面樣式 */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 140px);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 1.75rem;
    margin-top: 16px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

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

.input-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

.input-control:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary));
    color: #0c1221;
    border: none;
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn:hover:not(.btn-primary) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
    border: none;
}

.btn-danger:hover {
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
    opacity: 0.9;
}

/* 提示訊息 Alert */
.alert-container {
    margin-bottom: 24px;
}

.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.alert-info {
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid rgba(0, 242, 254, 0.2);
    color: var(--color-primary);
}

.alert-close {
    cursor: pointer;
    opacity: 0.7;
    transition: 0.2s;
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1rem;
}

.alert-close:hover {
    opacity: 1;
}

/* Dashboard Statistics / Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--border-color);
}

.stat-card.primary { border-left-color: var(--color-primary); }
.stat-card.warning { border-left-color: var(--color-warning); }
.stat-card.danger { border-left-color: var(--color-danger); }
.stat-card.success { border-left-color: var(--color-success); }
.stat-card.purple { border-left-color: var(--color-purple); }

.stat-info h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-icon {
    font-size: 2.25rem;
    opacity: 0.25;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-tab {
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.filter-tab:hover, .filter-tab.active {
    color: #0c1221;
    background: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}

.search-box {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.search-box input {
    padding-right: 40px;
}

.search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Tables / Grid View */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

th, td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: rgba(12, 18, 33, 0.4);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* 狀態徽章 Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-info {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.sync-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.sync-synced {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.sync-pending {
    background: rgba(245, 158, 11, 0.10);
    color: #f59e0b;
}

/* 案件詳情 - Split View */
.detail-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 32px;
    align-items: start;
}

@media (max-width: 992px) {
    .detail-layout {
        grid-template-columns: 1fr;
    }
}

/* 對話串檢視 (Chat bubble styles) */
.dialogue-pane {
    max-height: 70vh;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bubble {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 專員泡泡：靠左 */
.bubble.agent {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}

/* 客戶泡泡：靠右 */
.bubble.client {
    align-self: flex-end;
    background: rgba(var(--color-primary-rgb), 0.08);
    border: 1px solid rgba(var(--color-primary-rgb), 0.15);
    border-top-right-radius: 4px;
}

.bubble-sender {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

/* AI Highlight 樣式 */
.highlight-warning {
    background: rgba(239, 68, 68, 0.25);
    border-bottom: 2px dashed var(--color-danger);
    padding: 2px 4px;
    border-radius: 2px;
    color: #f87171;
    font-weight: 500;
}

.highlight-loan {
    background: rgba(245, 158, 11, 0.25);
    border-bottom: 2px dashed var(--color-warning);
    padding: 2px 4px;
    border-radius: 2px;
    color: #fbbf24;
    font-weight: 500;
}

.highlight-marketing {
    background: rgba(16, 185, 129, 0.25);
    border-bottom: 2px dashed var(--color-success);
    padding: 2px 4px;
    border-radius: 2px;
    color: #34d399;
    font-weight: 500;
}

.highlight-standard {
    background: rgba(168, 85, 247, 0.25);
    border-bottom: 2px dashed var(--color-purple);
    padding: 2px 4px;
    border-radius: 2px;
    color: #c084fc;
    font-weight: 500;
}

/* Right-side forms */
.detail-info-panel h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.case-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
    font-size: 0.85rem;
}

.case-meta-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
}

.case-meta-label {
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.case-meta-value {
    font-weight: 600;
}

/* Role Forms */
.role-form-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.role-form-card.active-role {
    border-color: rgba(var(--color-primary-rgb), 0.3);
    background: rgba(var(--color-primary-rgb), 0.01);
}

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

.role-title {
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-quote-box {
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid var(--text-muted);
    padding: 10px 14px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

.role-form-card.active-role .ai-quote-box {
    border-left-color: var(--color-primary);
}

/* User Management (users.html) */
.user-management-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 32px;
    align-items: start;
}

@media (max-width: 992px) {
    .user-management-layout {
        grid-template-columns: 1fr;
    }
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
}

.checkbox-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
}

/* Sync UI in settings.html */
.sync-section {
    text-align: center;
    padding: 40px 20px;
}

.sync-status-display {
    margin-bottom: 24px;
}

.pulse-button {
    position: relative;
    overflow: hidden;
}

.pulse-button::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: var(--color-primary);
    border-radius: inherit;
    z-index: -1;
    opacity: 0.4;
    transform: scale(1);
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.4); opacity: 0; }
}

footer {
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 16px 0;
        gap: 12px;
    }
    .nav-links {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 12px;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-box {
        max-width: 100%;
    }
}
