/* Material 3 Variables */
:root {
    --md-sys-color-primary: #0061A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #D1E4FF;
    --md-sys-color-on-primary-container: #001D36;
    --md-sys-color-secondary: #535F70;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #D7E3F7;
    --md-sys-color-on-secondary-container: #101C2B;
    --md-sys-color-tertiary: #6B5778;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #F2DAFF;
    --md-sys-color-on-tertiary-container: #251431;
    --md-sys-color-error: #BA1A1A;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-on-error-container: #410002;
    --md-sys-color-background: #FDFCFF;
    --md-sys-color-on-background: #1A1C1E;
    --md-sys-color-surface: #FDFCFF;
    --md-sys-color-on-surface: #1A1C1E;
    --md-sys-color-surface-variant: #DFE2EB;
    --md-sys-color-on-surface-variant: #43474E;
    --md-sys-color-outline: #73777F;
    --md-sys-elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
    --md-sys-elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
    --md-sys-elevation-3: 0px 1px 3px 0px rgba(0, 0, 0, 0.3), 0px 4px 8px 3px rgba(0, 0, 0, 0.15);

    --md-ref-typeface-brand: 'Roboto Flex', sans-serif;
    --md-ref-typeface-plain: 'Roboto Flex', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--md-ref-typeface-plain);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.5;
}

[x-cloak] {
    display: none !important;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--md-ref-typeface-brand);
    font-weight: 400;
}

/* Material Icons */
.material-symbols-outlined {
    font-size: 24px;
    vertical-align: middle;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 24px;
    height: 40px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.btn-filled:hover {
    box-shadow: var(--md-sys-elevation-1);
    opacity: 0.9;
}

.btn-outlined {
    background-color: transparent;
    border: 1px solid var(--md-sys-color-outline);
    color: var(--md-sys-color-primary);
}

.btn-outlined:hover {
    background-color: rgba(0, 97, 164, 0.08);
    /* Primary with opacity */
}

.btn-text {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    padding: 0 12px;
}

.btn-text:hover {
    background-color: rgba(0, 97, 164, 0.08);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

/* Chips */
.chip {
    display: inline-flex;
    align-items: center;
    height: 24px;
    /* Smaller height for table */
    padding: 0 8px;
    border-radius: 6px;
    border: 1px solid var(--md-sys-color-outline);
    background-color: transparent;
    color: var(--md-sys-color-on-surface);
    font-size: 12px;
    margin-right: 4px;
    margin-bottom: 4px;
    white-space: nowrap;
}

.chip-filled {
    border: none;
    color: #fff;
    /* Ensure text is readable on colored chips */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Data Table */
.data-table-container {
    width: 100%;
    overflow-x: auto;
    background-color: var(--md-sys-color-surface);
    border-radius: 16px;
    box-shadow: var(--md-sys-elevation-1);
    margin-top: 16px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
    /* Wider min-width for new columns */
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
    border-bottom: 1px solid var(--md-sys-color-surface-variant);
    cursor: pointer;
    user-select: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table th:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.data-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    border-bottom: 1px solid var(--md-sys-color-surface-variant);
    vertical-align: middle;
}

.data-table tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Visual Grouping Indicator */
.data-table tr.group-start {
    border-top: 2px solid var(--md-sys-color-outline);
    /* Stronger visual separation */
}

.data-table tr td:first-child {
    border-left: 4px solid transparent;
    /* Indicator strip */
}

/* Login Screen */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-image: url('assets/img/kommis1.webp');
    /* Use correct variable or path */
    background-size: cover;
    background-position: center;
    /* Added Overlay for readability */
    position: relative;
}

.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    /* Dark overlay */
    z-index: 1;
}

.login-card {
    position: relative;
    z-index: 2;
    background-color: rgba(255, 255, 255, 0.95);
    /* More opaque */
    padding: 48px;
    border-radius: 28px;
    box-shadow: var(--md-sys-elevation-3);
    text-align: center;
    /* layout adjustments */
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 450px;
    width: 90%;
}

.login-logo {
    height: 60px;
    margin-bottom: 16px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--md-sys-color-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--md-sys-color-secondary);
    margin-bottom: 32px;
}

.login-box-row {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.login-kommis-img {
    height: 80px;
    /* Determine size */
    object-fit: contain;
}

/* App Layout */
.app-bar {
    background-color: var(--md-sys-color-surface);
    padding: 0 24px;
    height: 72px;
    /* Slightly taller */
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--md-sys-elevation-1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-bar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-bar-logo {
    height: 40px;
}

.app-bar-title {
    font-size: 22px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.main-content {
    padding: 24px;
    max-width: 1600px;
    /* Wider for more columns */
    margin: 0 auto;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 24px;
}

.search-field {
    display: flex;
    align-items: center;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: 28px;
    height: 56px;
    padding: 0 16px;
    flex: 1;
    min-width: 300px;
}

.search-field input {
    border: none;
    background: transparent;
    height: 100%;
    width: 100%;
    margin-left: 8px;
    font-size: 16px;
    color: var(--md-sys-color-on-surface-variant);
}

.search-field input:focus {
    outline: none;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-dialog {
    background-color: var(--md-sys-color-surface);
    border-radius: 28px;
    padding: 24px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--md-sys-elevation-3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 24px;
    color: var(--md-sys-color-on-surface);
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px;
    font-size: 16px;
    background-color: transparent;
    color: var(--md-sys-color-on-surface);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: 2px solid var(--md-sys-color-primary);
    border-color: transparent;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background-color: #E8F5E9;
    color: #1B5E20;
}

.badge-warning {
    background-color: #FFF3E0;
    color: #E65100;
}

.badge-error {
    background-color: #FFEBEE;
    color: #B71C1C;
}

.badge-neutral {
    background-color: #F5F5F5;
    color: #616161;
}

/* Warnings */
.warning-banner {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Thumbnails in table */
.table-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    background-color: #EEEEEE;
    vertical-align: middle;
    border: 1px solid #ddd;
}

/* Drawer */
.drawer-container {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 450px;
    background-color: var(--md-sys-color-surface);
    box-shadow: var(--md-sys-elevation-2);
    z-index: 900;
    padding: 0;
    /* padding handled inside sections */
    overflow-y: auto;
    transition: transform 0.3s ease;
    transform: translateX(100%);
}

.drawer-container.open {
    transform: translateX(0);
}

.drawer-header {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-header h2 {
    font-size: 18px;
    /* Smaller title as requested */
    font-weight: 500;
    margin: 0;
}

.drawer-content {
    padding: 24px;
}

.drawer-section {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--md-sys-color-outline);
    padding-bottom: 16px;
}

.drawer-section:last-child {
    border-bottom: none;
}

.drawer-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--md-sys-color-primary);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 8px;
    align-items: baseline;
}

.info-label {
    font-size: 13px;
    color: var(--md-sys-color-secondary);
    font-weight: 500;
}

.info-value {
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    word-break: break-all;
}