/* ══════════════════════════════════════════════════════════════
   Department Detail page  (prefix: dd-)
   Route: /settings/departments/{id}
   ══════════════════════════════════════════════════════════════ */

/* ── Keyframes ─────────────────────────────────────────────── */

@keyframes dd-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes dd-shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: calc(400px + 100%) 0; }
}

@keyframes dd-fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Back button row ───────────────────────────────────────── */

.dd-back-row {
    margin-bottom: 20px;
}

.dd-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #6B7280;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 0;
    transition: color 150ms;
    font-family: inherit;
}

.dd-back-btn:hover { color: #111827; }

/* ── Page header ───────────────────────────────────────────── */

.dd-page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.dd-page-title {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin: 0;
    flex: 1;
    min-width: 0;
}

.dd-status-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 9999px;
    flex-shrink: 0;
}

.dd-status-badge--active {
    background: #ECFDF5;
    color: #10B981;
}

.dd-status-badge--inactive {
    background: #F3F4F6;
    color: #9CA3AF;
}

.dd-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.dd-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: #6B7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 150ms;
}

.dd-icon-btn:hover {
    background: #EEF2FF;
    color: #6366F1;
    border-color: #C7D2FE;
}

/* ── Stats bar ─────────────────────────────────────────────── */

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

.dd-stat-card {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dd-stat-label {
    font-size: 12px;
    font-weight: 500;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dd-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
}

.dd-stat-sub {
    font-size: 12px;
    color: #6B7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Two-column body ───────────────────────────────────────── */

.dd-body {
    display: grid;
    grid-template-columns: 55fr 45fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: start;
}

/* ── Cards ─────────────────────────────────────────────────── */

.dd-card {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    overflow: hidden;
}

.dd-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #F3F4F6;
}

.dd-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dd-card-count {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 9999px;
    background: #EEF2FF;
    color: #6366F1;
}

.dd-card-body {
    padding: 0;
}

/* ── Member rows ───────────────────────────────────────────── */

.dd-member-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #F9FAFB;
    transition: background 120ms;
}

.dd-member-row:last-child { border-bottom: none; }

.dd-member-row:hover { background: #F9FAFB; }

.dd-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #EEF2FF;
    color: #6366F1;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
}

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

.dd-member-name {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dd-member-title {
    font-size: 12px;
    color: #6B7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dd-team-chip {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 9999px;
    background: #F3F4F6;
    color: #6B7280;
    white-space: nowrap;
    flex-shrink: 0;
}

.dd-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 8px;
    color: #9CA3AF;
}

.dd-empty-state svg { color: #D1D5DB; }

.dd-empty-title {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin: 0;
}

.dd-empty-sub {
    font-size: 13px;
    color: #9CA3AF;
    margin: 0;
}

.dd-card-footer {
    padding: 12px 20px;
    border-top: 1px solid #F3F4F6;
    display: flex;
    justify-content: flex-end;
}

/* ── Team rows ─────────────────────────────────────────────── */

.dd-team-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #F9FAFB;
    transition: background 120ms;
}

.dd-team-row:last-child { border-bottom: none; }

.dd-team-row:hover { background: #F9FAFB; }

.dd-team-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #EEF2FF;
    color: #6366F1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

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

.dd-team-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.dd-team-desc {
    font-size: 12px;
    color: #6B7280;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dd-team-lead {
    font-size: 12px;
    color: #6B7280;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.dd-team-lead svg { color: #9CA3AF; }

.dd-team-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ── Working hours card ────────────────────────────────────── */

.dd-hours-card {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.dd-hours-body {
    padding: 20px;
}

.dd-hours-hint {
    font-size: 13px;
    color: #9CA3AF;
    margin: 0 0 16px 0;
    font-style: italic;
}

.dd-hours-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.dd-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dd-form-label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.dd-form-input,
.dd-form-select,
.dd-form-textarea {
    padding: 9px 12px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: #FFFFFF;
    color: #111827;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    width: 100%;
}

.dd-form-input:focus,
.dd-form-select:focus,
.dd-form-textarea:focus {
    outline: none;
    border-color: #6366F1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.dd-form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.dd-form-textarea {
    resize: vertical;
    min-height: 80px;
}

.dd-form-required { color: #EF4444; }

.dd-form-error {
    padding: 10px 14px;
    border-radius: 8px;
    background: #FEF2F2;
    color: #EF4444;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid #FECACA;
}

.dd-field-error {
    font-size: 12px;
    color: #EF4444;
    padding: 6px 10px;
    background: rgba(239, 68, 68, 0.06);
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.15);
    margin-bottom: 12px;
}

/* ── Day chips ─────────────────────────────────────────────── */

.dd-days-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.dd-day-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    border: 1.5px solid #E5E7EB;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    font-family: inherit;
}

.dd-day-chip input[type="checkbox"] { display: none; }

.dd-day-chip:hover {
    border-color: #6366F1;
    color: #6366F1;
}

.dd-day-chip--active {
    background: #6366F1;
    border-color: #6366F1;
    color: #FFFFFF;
    font-weight: 600;
}

/* ── Action buttons ────────────────────────────────────────── */

.dd-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 150ms;
    white-space: nowrap;
    font-family: inherit;
    background: none;
}

.dd-action-btn--primary {
    background: #6366F1;
    color: #FFFFFF;
    border-color: #6366F1;
}

.dd-action-btn--primary:hover:not(:disabled) {
    background: #4F46E5;
    border-color: #4F46E5;
}

.dd-action-btn--primary:disabled { opacity: 0.6; cursor: not-allowed; }

.dd-action-btn--ghost {
    background: #F9FAFB;
    color: #374151;
    border-color: #E5E7EB;
}

.dd-action-btn--ghost:hover { background: #F3F4F6; border-color: #D1D5DB; }

.dd-action-btn--danger {
    background: transparent;
    color: #EF4444;
    border-color: #FCA5A5;
}

.dd-action-btn--danger:hover { background: #FEF2F2; border-color: #EF4444; }

.dd-icon-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #E5E7EB;
    background: transparent;
    color: #6B7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 150ms;
}

.dd-icon-action-btn:hover {
    background: #EEF2FF;
    color: #6366F1;
    border-color: #C7D2FE;
}

.dd-icon-action-btn--danger:hover {
    background: #FEF2F2;
    color: #EF4444;
    border-color: #FCA5A5;
}

/* ── Spinner ───────────────────────────────────────────────── */

.dd-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: dd-spin 0.6s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

/* ── Loading / error page states ───────────────────────────── */

.dd-loading-center,
.dd-error-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    gap: 12px;
    text-align: center;
}

.dd-loading-text {
    font-size: 14px;
    color: #6B7280;
    margin: 0;
}

.dd-error-msg {
    font-size: 14px;
    color: #EF4444;
    margin: 0;
}

/* ── Skeleton rows ─────────────────────────────────────────── */

.dd-skeleton {
    background: linear-gradient(90deg, #F3F4F6 25%, #E9EAEC 50%, #F3F4F6 75%);
    background-size: 400px 100%;
    animation: dd-shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

.dd-skeleton--circle { border-radius: 50%; }

.dd-member-skeleton {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #F9FAFB;
}

/* ── Blurry modal backdrop ─────────────────────────────────── */

.dd-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 800;
    padding: 1rem;
}

/* ── Modal ─────────────────────────────────────────────────── */

.dd-modal {
    background: #FFFFFF;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.dd-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #E5E7EB;
}

.dd-modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.dd-modal-close {
    background: none;
    border: none;
    color: #6B7280;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.dd-modal-close:hover { color: #111827; }

.dd-modal-body {
    padding: 1.25rem 1.5rem;
}

.dd-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #E5E7EB;
}

/* ── Manager preview in modal ──────────────────────────────── */

.dd-manager-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: #EEF2FF;
    border: 1px solid #C7D2FE;
    margin-top: 0.5rem;
}

.dd-manager-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #6366F1;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dd-manager-name { font-weight: 600; font-size: 14px; color: #111827; }
.dd-manager-sub { font-size: 12px; color: #6B7280; }

/* ── Schedule section in edit modal ───────────────────────── */

.dd-schedule-section {
    border-top: 1px solid #E5E7EB;
    padding-top: 1rem;
    margin-top: 0.25rem;
}

.dd-schedule-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 12px;
    font-weight: 600;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.dd-schedule-hint {
    font-size: 12px;
    color: #9CA3AF;
    margin-bottom: 12px;
    font-style: italic;
}

.dd-schedule-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ── btn-primary override ──────────────────────────────────── */

.dd-modal-footer .btn.btn-primary {
    background-color: #6366F1;
    border-color: #6366F1;
    color: #FFFFFF;
}

.dd-modal-footer .btn.btn-primary:hover:not(:disabled) {
    background-color: #4F46E5;
    border-color: #4F46E5;
}

.dd-modal-footer .btn.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Mobile ────────────────────────────────────────────────── */

@media (max-width: 960px) {
    .dd-stats { grid-template-columns: repeat(2, 1fr); }
    .dd-body { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .dd-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .dd-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .dd-page-title { font-size: 20px; }
    .dd-stats { grid-template-columns: repeat(2, 1fr); }
    .dd-hours-grid { grid-template-columns: 1fr; }
    .dd-schedule-row { grid-template-columns: 1fr; }

    .dd-team-actions {
        flex-direction: column;
        align-items: flex-start;
    }
}
