/* ===== Service Desk Module ===== */

.sd-app {
    display: flex;
    min-height: calc(100vh - 72px);
}

/* ===== Sidebar ===== */
.sd-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--color-bg-soft);
    border-right: 1px solid var(--color-border);
    padding: 24px;
    overflow-y: auto;
}

.sd-sidebar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-dark);
    margin-bottom: 24px;
}

.sd-new-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}
.sd-plus { font-size: 18px; font-weight: 700; }

/* Queues */
.sd-section { margin-bottom: 24px; }
.sd-section-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}

.sd-queue-list { list-style: none; }
.sd-queue {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    color: var(--color-text-body);
    transition: background 0.12s;
}
.sd-queue:hover { background: #F1F5F9; }
[data-theme="dark"] .sd-queue:hover { background: rgba(255,255,255,0.05); }
.sd-queue.active { background: #EFF6FF; color: var(--color-primary); font-weight: 600; }
[data-theme="dark"] .sd-queue.active { background: rgba(37,99,235,0.15); }

.sd-queue-icon { flex-shrink: 0; color: var(--color-text-muted); }
.sd-queue.active .sd-queue-icon { color: var(--color-primary); }
.sd-queue-name { flex: 1; }
.sd-queue-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border-radius: 10px;
    padding: 1px 8px;
}
.sd-queue.active .sd-queue-count { background: #fff; color: var(--color-primary); }

/* Filters */
.sd-filter-list { list-style: none; }
.sd-filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 14px;
    color: var(--color-text-body);
    cursor: pointer;
}
.sd-filter-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2563EB;
    cursor: pointer;
}
.sd-filter-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sd-filter-dot.high   { background: #DC2626; }
.sd-filter-dot.normal { background: #2563EB; }
.sd-filter-dot.low    { background: #64748B; }

/* ===== Main content ===== */
.sd-main {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.sd-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.sd-table-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-dark);
}
.sd-table-count {
    font-weight: 400;
    color: var(--color-text-muted);
}

.sd-table-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sd-search { position: relative; }
.sd-search-input {
    width: 260px;
    height: 40px;
    padding: 0 14px 0 38px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--color-text-body);
    background: var(--color-bg);
}
.sd-search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.sd-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

.sd-icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: none;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s;
}
.sd-icon-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ===== Tickets table ===== */
.sd-table-wrap {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
}

.sd-table {
    width: 100%;
    border-collapse: collapse;
}

.sd-table thead th {
    height: 48px;
    padding: 0 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    background: var(--color-bg-soft);
    border-bottom: 1px solid var(--color-border);
}

.sd-table tbody tr {
    height: 56px;
    cursor: pointer;
    transition: background 0.12s;
}
.sd-table tbody tr:hover { background: var(--color-bg-soft); }
.sd-table tbody tr:not(:last-child) td { border-bottom: 1px solid var(--color-border); }

.sd-table td {
    padding: 0 16px;
    font-size: 14px;
    color: var(--color-text-body);
    vertical-align: middle;
}

.sd-ticket-id {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
}

.sd-ticket-title-cell { display: flex; flex-direction: column; max-width: 400px; }
.sd-ticket-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--color-text-body);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sd-ticket-desc {
    font-size: 13px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badges */
.sd-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.sd-badge.prio-high   { background: #FEE2E2; color: #DC2626; }
.sd-badge.prio-normal { background: #EFF6FF; color: #2563EB; }
.sd-badge.prio-low    { background: #F1F5F9; color: #64748B; }

[data-theme="dark"] .sd-badge.prio-high   { background: rgba(220,38,38,0.15); }
[data-theme="dark"] .sd-badge.prio-normal { background: rgba(37,99,235,0.15); }
[data-theme="dark"] .sd-badge.prio-low    { background: rgba(100,116,139,0.15); }

.sd-badge.status-new       { background: #ECFEFF; color: #0EA5E9; }
.sd-badge.status-open      { background: #EFF6FF; color: #2563EB; }
.sd-badge.status-waiting   { background: #FFFBEB; color: #F59E0B; }
.sd-badge.status-closed    { background: #ECFDF5; color: #16A34A; }
.sd-badge.unassigned       { background: #F1F5F9; color: #64748B; }

[data-theme="dark"] .sd-badge.status-new     { background: rgba(14,165,233,0.15); }
[data-theme="dark"] .sd-badge.status-open    { background: rgba(37,99,235,0.15); }
[data-theme="dark"] .sd-badge.status-waiting { background: rgba(245,158,11,0.15); }
[data-theme="dark"] .sd-badge.status-closed  { background: rgba(22,163,74,0.15); }
[data-theme="dark"] .sd-badge.unassigned     { background: rgba(100,116,139,0.15); }

.sd-sla {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
}
.sd-sla.ok { color: #16A34A; }
.sd-sla.breach { color: #DC2626; }

/* Person cell */
.sd-person {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sd-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2563EB;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Row actions */
.sd-row-actions { display: flex; gap: 4px; }
.sd-row-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}
.sd-row-btn:hover { color: var(--color-primary); background: var(--color-bg-soft); }

/* ===== Detail View ===== */
.sd-detail { display: none; }
.sd-detail.active { display: block; }

.sd-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-primary);
    background: none;
    border: none;
    cursor: pointer;
    margin-bottom: 24px;
    padding: 4px 0;
}
.sd-back-btn:hover { text-decoration: underline; }

.sd-detail-header { margin-bottom: 24px; }
.sd-detail-id {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}
.sd-detail-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text-dark);
}

/* Detail grid */
.sd-detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
}

/* Cards */
.sd-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
}

.sd-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-dark);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Description card */
.sd-desc {
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text-body);
}

/* Comments */
.sd-comments-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-dark);
    margin-top: 8px;
    margin-bottom: 16px;
}

.sd-comment {
    background: var(--color-bg-soft);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.sd-comment-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.sd-comment-author {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-dark);
}
.sd-comment-date {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-left: auto;
}
.sd-comment-body {
    font-size: 14px;
    color: var(--color-text-body);
    line-height: 1.5;
}

.sd-comment-form {
    margin-top: 16px;
}
.sd-comment-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--color-text-body);
    background: var(--color-bg);
    resize: vertical;
}
.sd-comment-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.sd-comment-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}
.sd-attach-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}
.sd-attach-btn:hover { color: var(--color-primary); }

/* Segmented control */
.sd-segmented {
    display: flex;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}
.sd-seg-btn {
    flex: 1;
    padding: 8px 12px;
    background: var(--color-bg);
    border: none;
    border-left: 1px solid var(--color-border);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.sd-seg-btn:first-child { border-left: none; }
.sd-seg-btn:hover { background: var(--color-bg-soft); }
.sd-seg-btn.active.high   { background: #FEE2E2; color: #DC2626; }
.sd-seg-btn.active.normal { background: #EFF6FF; color: #2563EB; }
.sd-seg-btn.active.low    { background: #F1F5F9; color: #64748B; }
[data-theme="dark"] .sd-seg-btn.active.high   { background: rgba(220,38,38,0.2); }
[data-theme="dark"] .sd-seg-btn.active.normal { background: rgba(37,99,235,0.2); }
[data-theme="dark"] .sd-seg-btn.active.low    { background: rgba(100,116,139,0.2); }

/* Status dropdown */
.sd-select, .sd-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--color-text-body);
    background: var(--color-bg);
}
.sd-select:focus, .sd-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Assignment */
.sd-assign-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.sd-assign-row .sd-avatar { width: 32px; height: 32px; font-size: 12px; }
.sd-assign-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-body);
}

/* SLA card */
.sd-sla-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}
.sd-sla-row .sd-label { color: var(--color-text-muted); }
.sd-sla-row .sd-value { font-weight: 600; }
.sd-sla-bar {
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}
.sd-sla-fill {
    height: 100%;
    background: #16A34A;
    border-radius: 3px;
}
.sd-sla-fill.warn { background: #F59E0B; }
.sd-sla-fill.breach { background: #DC2626; }

/* Attachments */
.sd-attach-list { list-style: none; }
.sd-attach-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    color: var(--color-text-body);
    border-bottom: 1px solid var(--color-border);
}
.sd-attach-item:last-child { border-bottom: none; }
.sd-attach-item svg { flex-shrink: 0; }
.sd-attach-name { flex: 1; }
.sd-attach-size { font-size: 12px; color: var(--color-text-muted); }

/* Timeline */
.sd-timeline { list-style: none; position: relative; padding-left: 20px; margin-top: 8px; }
.sd-timeline::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--color-border);
}
.sd-timeline-item { position: relative; padding-bottom: 14px; }
.sd-timeline-item:last-child { padding-bottom: 0; }
.sd-timeline-dot {
    position: absolute;
    left: -20px;
    top: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-primary);
}
.sd-timeline-date {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}
.sd-timeline-text {
    font-size: 13px;
    color: var(--color-text-body);
}

/* ===== New ticket modal ===== */
.sd-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.sd-modal-overlay.open { display: flex; }

.sd-modal {
    width: 600px;
    max-width: 100%;
    max-height: 90vh;
    background: var(--color-bg);
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sd-modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sd-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-dark);
}
.sd-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
}
.sd-modal-close:hover { color: var(--color-text-dark); }

.sd-modal-body {
    padding: 24px 32px;
    overflow-y: auto;
    flex: 1;
}

.sd-field { margin-bottom: 18px; }
.sd-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-body);
    margin-bottom: 6px;
}

.sd-textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--color-text-body);
    background: var(--color-bg);
    resize: vertical;
}
.sd-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.sd-upload {
    border: 2px dashed var(--color-border);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    font-size: 14px;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: border-color 0.15s;
}
.sd-upload:hover { border-color: var(--color-primary); }

.sd-modal-footer {
    padding: 16px 32px;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sd-detail-grid { grid-template-columns: 1fr; }
    .sd-table td:nth-child(6),
    .sd-table th:nth-child(6) { display: none; }
}

@media (max-width: 768px) {
    .sd-app { flex-direction: column; }

    .sd-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        max-height: 280px;
    }

    .sd-main { padding: 20px; }

    .sd-table-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .sd-search-input { width: 100%; }

    .sd-table td:nth-child(4),
    .sd-table th:nth-child(4),
    .sd-table td:nth-child(5),
    .sd-table th:nth-child(5),
    .sd-table td:nth-child(7),
    .sd-table th:nth-child(7) { display: none; }
}
