/* ==============================================
   Jönköping Kommun - Utvecklingssamtal (mallhantering)
   Feature-specific styles
   ============================================== */

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    color: var(--gray-dark);
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--cl-hard);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb .material-icons {
    font-size: 16px;
    color: var(--gray);
}

/* Student context bar */
.student-context-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--gray-lighter);
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.student-context-bar__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--cl-soft);
}

.student-context-bar__info {
    flex: 1;
}

.student-context-bar__name {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--gray-darker);
}

.student-context-bar__details {
    font-size: 0.875rem;
    color: var(--gray-dark);
}

/* Template assignment card */
.template-assignment-card {
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--gray-lighter);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    border-left: 4px solid var(--cl-hard);
}

.template-assignment-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.template-assignment-card__header .material-icons {
    color: var(--cl-hard);
    font-size: 22px;
}

.template-assignment-card__header h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-darker);
    margin: 0;
}

.template-assignment-card__body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px 16px;
    margin-bottom: 16px;
}

.template-assignment-card__field {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.template-assignment-card__label {
    font-size: 0.8125rem;
    color: var(--gray);
    font-weight: 500;
    white-space: nowrap;
}

.template-assignment-card__value {
    font-size: 0.875rem;
    color: var(--gray-darker);
    font-weight: 400;
}

.template-assignment-card__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid var(--gray-lighter);
}

/* "No template" state */
.template-assignment-card--empty {
    border-left-color: var(--gray);
    background: var(--gray-lightest);
}

.template-assignment-card--empty .template-assignment-card__header .material-icons {
    color: var(--gray);
}

/* Template box (dynamic content area) */
#template-box {
    margin-bottom: 16px;
}

.template-box__title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--cl-hard);
    margin-bottom: 4px;
}

.template-box__period {
    font-size: 0.8125rem;
    color: var(--gray-dark);
    margin-bottom: 8px;
}

.template-box__name {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-darker);
}

.template-box__version {
    font-size: 0.875rem;
    color: var(--gray-dark);
}

.template-box__assigned {
    font-size: 0.8125rem;
    color: var(--gray);
    margin-top: 4px;
}

.template-box__actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Buttons */
.vk-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1.4;
}

.vk-btn--primary {
    background-color: var(--cl-hard);
    color: var(--white);
}

.vk-btn--primary:hover {
    background-color: var(--cl-dark);
}

.vk-btn--text {
    background: transparent;
    color: var(--cl-hard);
    padding: 8px 12px;
}

.vk-btn--text:hover {
    background-color: var(--cl-super-soft);
}

.vk-btn--outlined {
    background: transparent;
    color: var(--cl-hard);
    border: 1px solid var(--cl-medium);
}

.vk-btn--outlined:hover {
    background-color: var(--cl-super-soft);
}

.vk-btn .material-icons {
    font-size: 18px;
}

/* MDC button (used in admin/dialog) */
.mdc-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--cl-hard);
    font-family: inherit;
}

.mdc-button:hover {
    background: var(--gray-lightest);
}

.mdc-button--unelevated {
    background: var(--cl-hard);
    color: var(--white);
}

.mdc-button--unelevated:hover {
    background: var(--cl-dark);
}

.mdc-button--outlined {
    border: 1px solid var(--gray-light);
    background: transparent;
    color: var(--gray-darker);
}

.mdc-button--outlined:hover {
    background: var(--gray-lightest);
}

/* Main tabs (Innan/Under/Efter) */
.main-tabs {
    margin-bottom: 0;
}

.main-tabs__wrapper {
    display: flex;
    border-bottom: 2px solid var(--gray-lighter);
    gap: 0;
}

.main-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--gray-dark);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    font-family: inherit;
}

.main-tab:hover {
    color: var(--cl-hard);
    background-color: var(--cl-super-soft);
}

.main-tab--active,
.main-tab.active {
    color: var(--cl-hard);
    border-bottom-color: var(--cl-hard);
}

.main-tab .material-icons {
    font-size: 18px;
}

/* Tab content */
.tab-content {
    display: none;
    padding: 20px 0;
}

.tab-content--active,
.tab-content.active {
    display: block;
}

/* Tab panels (used by script.js) */
.tab-panel {
    display: none;
    padding: 20px 0;
}

.tab-panel.active {
    display: block;
}

/* Template sections */
.template-section {
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--gray-lighter);
    padding: 20px;
    margin-bottom: 16px;
}

.template-section--staff-only {
    border-left: 3px solid var(--cl-yellow);
    background: #fffef6;
}

.template-section__title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-darker);
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-section__badge {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--cl-yellow-dark, #8a6d00);
    background: var(--cl-yellow-light, #fff3cd);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Template questions */
.template-questions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.template-question {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.template-question__label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-darker);
}

.template-question__input,
.form-field textarea,
.form-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-light);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s;
    background: var(--white);
}

.template-question__input:focus,
.form-field textarea:focus,
.form-field input:focus {
    border-color: var(--cl-hard);
    outline: none;
    box-shadow: 0 0 0 2px var(--cl-super-soft);
}

/* Form field (dynamic rendering) */
.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-darker);
    margin-bottom: 6px;
}

.section-header[data-section] {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-darker);
    padding: 12px 0 8px;
    border-bottom: 1px solid var(--gray-lighter);
    margin-bottom: 12px;
    margin-top: 16px;
}

/* Student sidebar */
.student-sidebar {
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--gray-lighter);
    padding: 16px;
    margin-top: 20px;
}

.student-sidebar__title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-darker);
    margin: 0 0 12px 0;
}

.student-sidebar__list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.student-sidebar__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.8125rem;
    color: var(--gray-darker);
    cursor: pointer;
    transition: background 0.15s;
}

.student-sidebar__item:hover {
    background: var(--gray-lightest);
}

.student-sidebar__item--active {
    background: var(--cl-super-soft);
    color: var(--cl-hard);
    font-weight: 500;
}

.student-sidebar__status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.student-sidebar__status--assigned {
    background: var(--cl-green);
}

.student-sidebar__status--unassigned {
    background: var(--gray-light);
}

/* Dialogs */
.vk-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.vk-dialog[aria-hidden="false"] {
    display: flex;
}

.mdc-dialog__scrim {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
}

.mdc-dialog__container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.mdc-dialog__surface {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mdc-dialog__title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-lighter);
}

.mdc-dialog__title h2 {
    font-size: 1.125rem;
    font-weight: 500;
    margin: 0;
    color: var(--gray-darker);
}

.mdc-dialog__content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.mdc-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--gray-lighter);
}

/* Confirm dialog specifics */
.confirm-dialog__from-to {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-lightest);
    border-radius: 6px;
    margin-bottom: 12px;
}

.confirm-dialog__from,
.confirm-dialog__to {
    flex: 1;
}

.confirm-dialog__label {
    font-size: 0.75rem;
    color: var(--gray);
    text-transform: uppercase;
    font-weight: 500;
    display: block;
    margin-bottom: 2px;
}

.confirm-dialog__arrow {
    color: var(--gray);
}

/* Alert/info boxes */
.alert {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    line-height: 1.5;
}

.alert--info {
    background: #e3f2fd;
    color: #1565c0;
}

.alert--warning {
    background: #fff3e0;
    color: #e65100;
}

.alert--success {
    background: #e8f5e9;
    color: #2e7d32;
}

.alert__icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.alert p {
    margin: 4px 0 0;
}

.alert strong {
    display: block;
    margin-bottom: 4px;
}

/* Template search (in dialog) */
.template-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--gray-light);
    border-radius: 4px;
    margin-bottom: 16px;
}

.template-search__icon {
    color: var(--gray);
    font-size: 20px;
}

.template-search__input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 0.875rem;
    font-family: inherit;
}

/* Template select table */
.template-select-table-wrapper {
    max-height: 300px;
    overflow-y: auto;
}

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

.template-select-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray);
    text-transform: uppercase;
    padding: 8px 12px;
    border-bottom: 2px solid var(--gray-lighter);
    position: sticky;
    top: 0;
    background: var(--white);
}

.template-select-table td {
    padding: 10px 12px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-lighter);
}

.template-select-row {
    cursor: pointer;
    transition: background 0.15s;
}

.template-select-row:hover {
    background: var(--cl-super-soft);
}

.template-select-row.selected,
.template-select-row--active {
    background: var(--cl-super-soft);
    border-left: 3px solid var(--cl-hard);
}

.template-select-row--none {
    color: var(--gray);
}

/* History timeline */
.history-timeline {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-timeline__item,
.history-entry {
    display: grid;
    grid-template-columns: 140px 1fr auto;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-lighter);
    font-size: 0.875rem;
    align-items: start;
}

.history-timeline__item:last-child,
.history-entry:last-child {
    border-bottom: none;
}

.history-timeline__date,
.history-date {
    font-size: 0.8125rem;
    color: var(--gray);
    font-variant-numeric: tabular-nums;
}

.history-timeline__event,
.history-event {
    color: var(--gray-darker);
    font-weight: 500;
}

.history-timeline__actor,
.history-actor {
    font-size: 0.8125rem;
    color: var(--gray-dark);
}

.history-from-to {
    font-size: 0.8125rem;
    color: var(--gray-dark);
    grid-column: 1 / -1;
    padding-left: 152px;
}

.history-dialog__subtitle {
    font-size: 0.875rem;
    color: var(--gray-dark);
    margin: 0 0 16px 0;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.6;
}

.status-badge--published {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge--draft {
    background: #fff3e0;
    color: #e65100;
}

.status-badge--inactive {
    background: var(--gray-lightest);
    color: var(--gray-dark);
}

/* Badge (compact) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1.6;
}

.badge--published {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge--draft {
    background: #fff3e0;
    color: #e65100;
}

.badge--inactive {
    background: var(--gray-lightest);
    color: var(--gray-dark);
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: #323232;
    color: var(--white);
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 0.875rem;
    z-index: 200;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    text-align: center;
}

.toast--visible {
    bottom: 24px;
}

/* Admin-specific styles */
.admin-stats-chips {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.admin-stats-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--white);
    border: 1px solid var(--gray-lighter);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.admin-stats-chip .material-icons {
    font-size: 18px;
}

.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-page-header h1 {
    font-size: 1.5rem;
    font-weight: 400;
    margin: 0;
    color: var(--gray-darker);
}

.admin-page-header p {
    font-size: 0.875rem;
    color: var(--gray-dark);
    margin: 4px 0 0;
}

/* Admin template table */
.admin-template-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-template-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray);
    text-transform: uppercase;
    border-bottom: 2px solid var(--gray-lighter);
    background: var(--gray-lightest);
}

.admin-template-table td {
    padding: 12px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-lighter);
    vertical-align: top;
}

.admin-template-table tbody tr:hover {
    background: var(--gray-lightest);
}

/* Template detail panel (expansion) */
.template-detail-row td {
    padding: 0;
    background: #fafafa;
}

.template-detail-panel {
    padding: 16px 24px;
    border-left: 3px solid var(--cl-hard);
}

.version-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-lighter);
    font-size: 0.875rem;
}

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

/* Structure preview */
.structure-preview {
    background: var(--white);
    border: 1px solid var(--gray-lighter);
    border-radius: 6px;
    padding: 16px;
    margin-top: 12px;
}

.structure-preview__title {
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0 0 12px 0;
}

.structure-preview__tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.8125rem;
    color: var(--gray-darker);
}

.structure-preview__tab .material-icons {
    font-size: 16px;
    color: var(--cl-hard);
}

/* Admin form dialog */
.admin-form-field {
    margin-bottom: 16px;
}

.admin-form-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-darker);
    margin-bottom: 6px;
}

.admin-form-field input,
.admin-form-field textarea,
.admin-form-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-light);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: inherit;
    box-sizing: border-box;
}

.admin-form-field input:focus,
.admin-form-field textarea:focus,
.admin-form-field select:focus {
    border-color: var(--cl-hard);
    outline: none;
    box-shadow: 0 0 0 2px var(--cl-super-soft);
}

.admin-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Utility classes */
.margin-top-s { margin-top: 8px; }
.margin-top-m { margin-top: 16px; }
.margin-top-l { margin-top: 24px; }
.margin-bottom-s { margin-bottom: 8px; }
.margin-bottom-m { margin-bottom: 16px; }
.text-muted { color: var(--gray-dark); }

/* Responsive */
@media (max-width: 959px) {
    .template-assignment-card__body {
        grid-template-columns: 1fr;
    }

    .history-timeline__item,
    .history-entry {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .history-from-to {
        padding-left: 0;
    }

    .confirm-dialog__from-to {
        flex-direction: column;
    }

    .confirm-dialog__arrow {
        transform: rotate(90deg);
    }
}

@media (max-width: 599px) {
    .main-tab {
        padding: 10px 12px;
        font-size: 0.8125rem;
    }

    .main-tab .material-icons {
        display: none;
    }

    .template-assignment-card {
        padding: 16px;
    }

    .template-assignment-card__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .mdc-dialog__container {
        padding: 8px;
    }

    .student-sidebar {
        display: none;
    }

    .admin-form-row {
        grid-template-columns: 1fr;
    }
}

/* Dark mode overrides */
body.dark-mode .template-assignment-card {
    background: var(--gray-darker);
    border-color: var(--gray-dark);
}

body.dark-mode .template-section {
    background: var(--gray-darker);
    border-color: var(--gray-dark);
}

body.dark-mode .template-section--staff-only {
    background: #2d2a1f;
}

body.dark-mode .template-question__input,
body.dark-mode .form-field textarea,
body.dark-mode .form-field input {
    background: var(--gray-dark);
    border-color: var(--gray);
    color: var(--gray-lightest);
}

body.dark-mode .student-context-bar {
    background: var(--gray-darker);
    border-color: var(--gray-dark);
}

body.dark-mode .mdc-dialog__surface {
    background: var(--gray-darker);
}

body.dark-mode .student-sidebar {
    background: var(--gray-darker);
    border-color: var(--gray-dark);
}

body.dark-mode .toast {
    background: var(--gray-lightest);
    color: var(--gray-darker);
}
