/* --- Social CRM Theme (InsightArk Inspired) --- */

/* Root Variables are managed in variables.css, but we enforce specific overrides here */
:root {
    --primary-color: #ff8855;
    --bg-body: #f8fafc;
    --text-main: #334155;
    --bg-sidebar: #ffffff;
}

/* Global Reset & Typography */
body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Light Theme Sidebar (InsightArk Style) */
.sidebar {
    width: 260px;
    background: #ffffff;
    color: #475569;
    display: flex;
    flex-direction: column;
    padding: 16px;
    border-right: 1px solid #e2e8f0;
    position: relative;
    z-index: 50;
    flex-shrink: 0;
    transition: width 0.3s ease;
}

.logo h2 {
    margin: 0;
    padding: 16px 0 16px 12px;
    text-align: left;
    font-weight: 800;
    font-size: 1.5rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo h2::before {
    content: '⚡️';
    font-size: 1.2rem;
}

.nav-links {
    list-style: none;
    padding: 0;
    margin-top: 24px;
}

.nav-links li {
    padding: 12px 20px;
    margin-bottom: 6px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #64748b;
    font-size: 1.05rem;
    user-select: none;
    -webkit-user-select: none;
}

.nav-links li:hover {
    background-color: #fff7ed;
    /* Light Orange */
    color: #ff8855;
}

.nav-links li.active {
    background-color: #ff8855;
    /* Vibrant Orange */
    color: white !important;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(255, 136, 85, 0.2);
}

/* Icons in nav：圖示 + 文字分開，避免字型未載入時整列像空白 */
.nav-links li span.material-symbols-rounded {
    font-size: 1.25rem;
    flex-shrink: 0;
    width: 1.5rem;
    text-align: center;
    font-family: 'Material Symbols Rounded', 'Noto Sans TC', sans-serif;
}

.nav-links li .nav-label {
    flex: 1;
    min-width: 0;
}

/* Layout */
#app {
    display: flex;
    width: 100%;
    height: 100%;
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Top Bar: Clean & Minimal */
.top-bar {
    height: 64px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 10;
}

#page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

/* Page Container */
#page-container {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    background: #f8fafc;
}

/* --- Social CRM Cards --- */
.card,
.panel,
.stat-card {
    background: #ffffff;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02), 0 4px 8px -2px rgba(0, 0, 0, 0.02);
    margin-bottom: 24px;
    transition: all 0.2s ease;
}

.card:hover,
.panel:hover,
.stat-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

/* Dashboard Grid Repossessed from previous step but styled for Social CRM */
.dashboard-welcome {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 32px;
}

.dashboard-welcome h1 {
    font-size: 1.8rem;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    border: 1px solid #e2e8f0;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.revenue {
    background: #fff7ed;
    color: #ff8855;
}

/* Orange tint */
.stat-icon.orders {
    background: #ecfccb;
    color: #65a30d;
}

/* Lime tint */
.stat-icon.alert {
    background: #fef2f2;
    color: #dc2626;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #1e293b;
    margin: 4px 0;
}

.stat-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.05em;
}

/* Buttons: Modern & Soft */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #ff8855;
    color: white;
    box-shadow: 0 2px 4px rgba(255, 136, 85, 0.2);
}

.btn-primary:hover {
    background: #f97316;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(255, 136, 85, 0.3);
}

.btn-white {
    background: white;
    border: 1px solid #e2e8f0;
    color: #475569;
}

.btn-white:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* Feed & Widget items */
.widget-item {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s;
    background: #f8fafc;
}

.widget-item:hover {
    background: white;
    border-color: #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* Inputs */
input,
select {
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    color: #334155;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: #ff8855;
    box-shadow: 0 0 0 3px rgba(255, 136, 85, 0.1);
}

/* Tables */
.modern-table th {
    background: #f8fafc;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 12px 16px;
}

.modern-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.user-cell span {
    font-weight: 500;
    color: #334155;
}

/* Dark Mode Overrides (Minimal support, user requested light theme primarily) */
[data-theme="dark"] body {
    background: #0f172a;
    color: #f1f5f9;
}

[data-theme="dark"] .sidebar,
[data-theme="dark"] .top-bar,
[data-theme="dark"] .card,
[data-theme="dark"] .panel {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .nav-links li {
    color: #94a3b8;
}

[data-theme="dark"] .nav-links li:hover {
    background: rgba(255, 136, 85, 0.1);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* 唯讀模式：隱藏會寫入/刪除資料的按鈕與表單 */
[data-crm-readonly="true"] .crm-write,
[data-crm-readonly="true"] [data-crm-write] {
    display: none !important;
}