/* ALF System — Custom Theme */

:root {
    --sidebar-width: 240px;
    --sidebar-collapsed: 72px;
    --card-radius: 20px;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
    --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
    --transition: 0.2s ease;
}

/* ── Light Theme ── pure white with neutral grays */
[data-theme-mode="light"] {
    --bg-page: #ffffff;
    --bg-sidebar: #fafafa;
    --bg-card: #ffffff;
    --bg-card-hover: #f7f7f8;
    --bg-input: #f4f4f5;
    --border-color: #e5e5e7;
    --text-primary: #0a0a0a;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --sidebar-active-bg: var(--accent-light);
    --sidebar-active-text: var(--accent);
}

/* ── Dark Theme ── pure black with near-black surfaces */
[data-theme-mode="dark"] {
    --bg-page: #000000;
    --bg-sidebar: #0a0a0a;
    --bg-card: #0f0f10;
    --bg-card-hover: #17171a;
    --bg-input: #1a1a1d;
    --border-color: #27272a;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --sidebar-active-bg: var(--accent-dark);
    --sidebar-active-text: var(--accent);
}

/* ── Accent Colors ──
   Purple matches the brand on https://neir0n.com (primary #c471ed).
   Default accent is set in base.html (data-accent="purple"). */
[data-accent="green"]  { --accent: #4d7c5e; --accent-light: #e8f0eb; --accent-dark: #1a3324; --accent-text: #fff; }
[data-accent="blue"]   { --accent: #3b72c4; --accent-light: #e6eef8; --accent-dark: #162d50; --accent-text: #fff; }
[data-accent="purple"] { --accent: #c471ed; --accent-light: #f7e7fe; --accent-dark: #3a1649; --accent-text: #fff; }
[data-accent="orange"] { --accent: #c47a3b; --accent-light: #f8ede6; --accent-dark: #4e2d16; --accent-text: #fff; }
[data-accent="red"]    { --accent: #c44b4b; --accent-light: #f8e6e6; --accent-dark: #4e1616; --accent-text: #fff; }
[data-accent="teal"]   { --accent: #3ba3a3; --accent-light: #e6f5f5; --accent-dark: #164040; --accent-text: #fff; }

/* ── Base ── */
body {
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    transition: width var(--transition);
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar .nav-text {
    opacity: 1;
    transition: opacity var(--transition);
    white-space: nowrap;
}
.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}
.sidebar .logo-text {
    transition: opacity var(--transition);
}
.sidebar.collapsed .logo-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
    text-decoration: none;
}
.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 10px;
}
.sidebar .nav-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.sidebar .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}
.sidebar .collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.sidebar .collapse-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.sidebar.collapsed .collapse-btn svg {
    transform: rotate(180deg);
}

/* ── Cards ── */
.card-custom {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition);
}
.card-custom:hover {
    box-shadow: var(--card-shadow-hover);
}
.card-custom .card-inner {
    padding: 20px;
}
.card-custom .card-inner-sm {
    padding: 16px;
}

/* ── Stats ── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
}
.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    color: var(--accent);
}
[data-theme-mode="dark"] .stat-card .stat-icon {
    background: var(--accent-dark);
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}
.stat-card .stat-sub {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Buttons ── */
.btn-accent {
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-accent:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
.btn-soft {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-soft:hover {
    background: var(--bg-card-hover);
}
.btn-sm-custom {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 8px;
}

/* ── Inputs ── */
.input-custom {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 14px;
    color: var(--text-primary);
    width: 100%;
    outline: none;
    transition: border-color var(--transition);
}
.input-custom:focus {
    border-color: var(--accent);
}
.input-custom::placeholder {
    color: var(--text-muted);
}
textarea.input-custom {
    resize: vertical;
    min-height: 80px;
}
select.input-custom {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* ── Badges ── */
.badge-custom {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 20px;
}
.badge-hot { background: #fef3c7; color: #92400e; }
.badge-warm { background: #ffedd5; color: #9a3412; }
.badge-cold { background: #dbeafe; color: #1e40af; }
.badge-client { background: #d1fae5; color: #065f46; }
.badge-repeat { background: #ede9fe; color: #5b21b6; }
.badge-new { background: #fef9c3; color: #854d0e; }
.badge-answered { background: #d1fae5; color: #065f46; }
.badge-on_screen { background: #dbeafe; color: #1e40af; }
.badge-deferred { background: #f3f4f6; color: #6b7280; }
.badge-hidden { background: #fee2e2; color: #991b1b; }
[data-theme-mode="dark"] .badge-hot { background: #78350f; color: #fde68a; }
[data-theme-mode="dark"] .badge-warm { background: #7c2d12; color: #fed7aa; }
[data-theme-mode="dark"] .badge-cold { background: #1e3a5f; color: #93c5fd; }
[data-theme-mode="dark"] .badge-client { background: #064e3b; color: #6ee7b7; }
[data-theme-mode="dark"] .badge-repeat { background: #3b0764; color: #c4b5fd; }
[data-theme-mode="dark"] .badge-new { background: #713f12; color: #fde68a; }
[data-theme-mode="dark"] .badge-answered { background: #064e3b; color: #6ee7b7; }
[data-theme-mode="dark"] .badge-on_screen { background: #1e3a5f; color: #93c5fd; }
[data-theme-mode="dark"] .badge-deferred { background: #374151; color: #9ca3af; }
[data-theme-mode="dark"] .badge-hidden { background: #7f1d1d; color: #fca5a5; }

/* ── Chip toggle (analytics filters) ── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.chip:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}
.chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.chip.active:hover {
    opacity: 0.92;
}
.chip-ghost {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
}
.chip-ghost:hover {
    border-style: solid;
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Preset cards (quick templates) ── */
.preset-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    min-height: 76px;
    width: 100%;
}
.preset-tile:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.preset-tile .preset-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.preset-tile .preset-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}
.preset-tile .preset-icon {
    font-size: 18px;
    line-height: 1;
    margin-bottom: 2px;
}

/* ── Loading shimmer ── */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.shimmer {
    background: linear-gradient(90deg,
        var(--bg-input) 0%,
        var(--bg-card-hover) 50%,
        var(--bg-input) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: 8px;
    color: transparent !important;
}

/* ── KPI hero (analytics total) ── */
.kpi-hero {
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}
.kpi-hero .kpi-value {
    font-size: clamp(40px, 6vw, 64px);
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.kpi-hero .kpi-label {
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}
.kpi-hero .kpi-sub {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Collapsible block (data table) ── */
details.collapsible > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 16px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 12px;
    transition: background var(--transition);
}
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before {
    content: "▸";
    transition: transform var(--transition);
    color: var(--text-muted);
}
details.collapsible[open] > summary::before {
    transform: rotate(90deg);
}
details.collapsible > summary:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* ── Tables ── */
.table-custom {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}
.table-custom th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border-color);
}
.table-custom th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background var(--transition), color var(--transition);
    position: relative;
}
.table-custom th.sortable:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}
.table-custom th.sortable:active {
    background: var(--bg-card-hover);
}
.table-custom th.sortable::after {
    content: "↕";
    margin-left: 6px;
    font-size: 11px;
    opacity: 0.55;
    display: inline-block;
    transition: opacity var(--transition), color var(--transition);
}
.table-custom th.sortable:hover::after {
    opacity: 1;
    color: var(--text-primary);
}
.table-custom th.sort-asc::after,
.table-custom th.sort-desc::after {
    opacity: 1;
    color: var(--accent);
    font-weight: 700;
}
.table-custom th.sort-asc::after {
    content: "↑";
}
.table-custom th.sort-desc::after {
    content: "↓";
}
.table-custom td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.table-custom tbody tr {
    transition: background var(--transition);
}
.table-custom tbody tr:hover {
    background: var(--bg-card-hover);
}
.table-custom tbody tr:last-child td {
    border-bottom: none;
}

/* ── Toggle ── */
.toggle-custom {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--border-color);
    cursor: pointer;
    transition: background var(--transition);
}
.toggle-custom.active {
    background: var(--accent);
}
.toggle-custom .toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform var(--transition);
}
.toggle-custom.active .toggle-knob {
    transform: translateX(20px);
}

/* ── Search ── */
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 8px 16px;
}
.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    flex: 1;
}
.search-box input::placeholder {
    color: var(--text-muted);
}

/* ── Tabs ── */
.tabs-custom {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    border-radius: 12px;
    padding: 4px;
}
.tabs-custom a {
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
}
.tabs-custom a:hover {
    color: var(--text-primary);
}
.tabs-custom a.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* ── Kanban ── */
.kanban-col {
    background: var(--bg-input);
    border-radius: 16px;
    min-height: 200px;
}
.kanban-col-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px;
    margin: 8px;
    box-shadow: var(--card-shadow);
    cursor: grab;
    transition: box-shadow var(--transition);
}
.kanban-card:hover {
    box-shadow: var(--card-shadow-hover);
}
.kanban-card.dragging {
    opacity: 0.4;
}

/* ── Progress ── */
.progress-custom {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-input);
    overflow: hidden;
}
.progress-custom .progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.3s ease;
}

/* ── Utility ── */
.text-accent { color: var(--accent); }
.bg-accent { background: var(--accent); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.border-theme { border-color: var(--border-color); }
.rounded-card { border-radius: var(--card-radius); }

/* ── Composer (broadcast) ── */
.composer-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 0;
    border-bottom: 1px solid var(--border-color);
}
.composer-section:last-child { border-bottom: none; }
.composer-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-primary);
    max-width: 260px;
}
.attachment-chip.removed {
    opacity: 0.4;
    text-decoration: line-through;
}
.attachment-chip .attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.attachment-chip .attachment-remove {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    background: none;
    border: none;
}
.attachment-chip .attachment-remove:hover { color: #991b1b; }

/* ── Row-card (dense horizontal list rows for scheduled & history) ── */
.row-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.row-card:hover {
    border-color: var(--text-muted);
    box-shadow: var(--card-shadow);
}
.row-card .row-time {
    flex-shrink: 0;
    min-width: 130px;
}
.row-card .row-time-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.row-card .row-main {
    flex: 1;
    min-width: 0;
}
.row-card .row-text {
    font-size: 14px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.row-card .row-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.row-card .row-actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
}

/* ── Icon button ── */
.icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.icon-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* ── Editor/Preview tabs ── */
.editor-pane { display: block; }
.editor-pane[hidden] { display: none; }
.preview-surface {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px;
    min-height: 200px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}
