:root {
    --app-space-1: 0.5rem;
    --app-space-2: 0.75rem;
    --app-space-3: 1rem;
    --app-space-4: 1.25rem;
    --app-space-5: 1.5rem;
}

.login-brand-logo {
    display: block;
    width: 100%;
    max-width: 240px;
    height: auto;
    margin: 0 auto;
}

.login-brand-title {
    display: block;
    margin-top: 0.35rem;
    color: var(--bs-body-color);
    font-size: 1.15rem;
    font-weight: 500;
    line-height: 1.25;
}

.brand-header-logo {
    display: block;
    width: auto;
    height: 2.15rem;
    object-fit: contain;
}

.app-header .brand-header-logo {
    flex: 0 0 auto;
}

.brand-header-title {
    display: block;
    max-width: 32rem;
    overflow: hidden;
    color: var(--bs-body-color);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-header .brand-header-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3.5rem;
}

.sidebar-brand {
    height: auto;
}

.sidebar-brand .brand-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 0;
    padding: 0.9rem 0.75rem 1rem;
}

.brand-sidebar-logo {
    display: block;
    width: 100%;
    max-width: 170px;
    height: auto;
    object-fit: contain;
}

.brand-sidebar-title {
    display: block;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.04em;
    text-align: center;
    white-space: nowrap;
}

.app-content {
    padding: var(--app-space-5);
}

.app-wrapper {
    min-height: 0;
}

.app-main {
    min-height: 0;
    overflow: visible;
}

body.layout-fixed.sidebar-expand-lg .app-main {
    overflow: visible;
}

.app-main,
.app-content,
.app-content > .container-fluid {
    min-width: 0;
}

.app-content > .container-fluid > .card {
    margin-bottom: var(--app-space-4);
}

.app-content > .container-fluid > .card + .card {
    margin-top: var(--app-space-4);
}

.card-header,
.card-body,
.card-footer {
    padding: var(--app-space-4);
}

.card-header .card-title {
    margin-bottom: 0;
}

.card-header + .card-body {
    padding-top: var(--app-space-4);
}

.card-body > .table-responsive,
.card-body > .dataTables_wrapper,
.card-body > .dt-container {
    margin-top: var(--app-space-2);
}

.table-responsive {
    max-width: 100%;
    overflow-x: auto;
    border-radius: 0.375rem;
}

.table {
    margin-bottom: 0;
}

#schedules-table,
#history-table {
    min-width: 900px;
}

.dt-container {
    min-width: 0;
}

.dt-container .dt-layout-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--app-space-2);
    align-items: center;
    margin-bottom: var(--app-space-2);
}

.dt-container .dt-layout-cell {
    min-width: 0;
}

.dt-container .dt-search input,
.dt-container .dt-length select {
    max-width: 100%;
}

.table > :not(caption) > * > * {
    padding: var(--app-space-2) var(--app-space-3);
    vertical-align: middle;
}

.table thead th {
    white-space: nowrap;
}

.schedule-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.photo-work-item {
    width: 160px;
}

.photo-work-item .photo-preview-button,
.photo-work-item .photo-preview-button img {
    display: block;
    width: 160px;
}

.card-body > form:not(:last-child),
.card-body > .row:not(:last-child) {
    margin-bottom: var(--app-space-4);
}

.form-label {
    margin-bottom: var(--app-space-1);
    font-weight: 600;
}

.form-text {
    margin-top: var(--app-space-1);
}

.small-box {
    margin-bottom: var(--app-space-4);
}

.modal-content .modal-header,
.modal-content .modal-body,
.modal-content .modal-footer {
    padding: var(--app-space-4);
}

#camera-upload-form .card-footer .btn {
    min-height: 2.75rem;
}

#photoViewerModal .modal-body {
    min-height: 12rem;
}

@media (max-width: 767.98px) {
    .brand-header-title {
        display: none;
    }

    .app-content {
        padding: var(--app-space-3);
    }

    .card-header,
    .card-body,
    .card-footer {
        padding: var(--app-space-3);
    }

    .table > :not(caption) > * > * {
        padding: var(--app-space-2);
    }

    .card-footer .btn,
    .card-footer a.btn {
        margin-bottom: var(--app-space-1);
    }

    .app-header .navbar-nav.ms-auto {
        min-width: 0;
    }

    .app-header .navbar-nav.ms-auto .nav-link {
        padding-left: var(--app-space-1);
        padding-right: var(--app-space-1);
        white-space: nowrap;
    }

    .app-header .navbar-nav.ms-auto > .nav-item:not(:first-child) .nav-link {
        font-size: 0;
    }

    .app-header .navbar-nav.ms-auto > .nav-item:not(:first-child) .nav-link i {
        font-size: 1rem;
        margin-right: 0 !important;
    }

    #schedules-table,
    #history-table {
        min-width: 760px;
    }

    #schedules-table {
        min-width: 0;
        display: block;
    }

    .schedule-table-responsive {
        overflow-x: visible;
    }

    #schedules-table thead {
        display: none;
    }

    #schedules-table tbody {
        display: grid;
        gap: var(--app-space-3);
    }

    #schedules-table tbody tr {
        display: grid;
        width: 100%;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "title status"
            "date department"
            "note note"
            "actions actions";
        gap: 0 var(--app-space-3);
        margin: 0;
        padding: var(--app-space-3);
        border: 1px solid var(--bs-border-color);
        border-radius: var(--bs-border-radius-lg);
        background-color: var(--bs-body-bg);
        box-shadow: var(--bs-box-shadow-sm);
    }

    #schedules-table tbody tr:hover {
        background-color: var(--bs-tertiary-bg);
    }

    #schedules-table tbody tr > td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
        background: transparent;
        --bs-table-bg-type: transparent;
        --bs-table-accent-bg: transparent;
        box-shadow: none !important;
    }

    #schedules-table tbody tr > td::before {
        display: block;
        margin-bottom: 0.15rem;
        color: var(--bs-secondary-color);
        content: attr(data-label);
        font-size: 0.72rem;
        font-weight: 600;
        letter-spacing: 0.02em;
    }

    #schedules-table tbody tr > .schedule-title {
        grid-area: title;
        font-weight: 600;
        font-size: 1rem;
    }

    #schedules-table tbody tr > .schedule-title::before,
    #schedules-table tbody tr > .schedule-status::before {
        display: none;
    }

    #schedules-table tbody tr > .schedule-status {
        grid-area: status;
        align-self: start;
        text-align: right;
    }

    #schedules-table tbody tr > .schedule-date {
        grid-area: date;
        margin-top: var(--app-space-3);
    }

    #schedules-table tbody tr > .schedule-department {
        grid-area: department;
        margin-top: var(--app-space-2);
        padding-left: var(--app-space-2);
    }

    #schedules-table tbody tr > .schedule-note {
        grid-area: note;
        margin-top: var(--app-space-2);
        overflow: hidden;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    #schedules-table tbody tr > .schedule-action-cell {
        grid-area: actions;
        margin-top: var(--app-space-3);
        padding-top: var(--app-space-3);
        border-top: 1px solid var(--bs-border-color-translucent);
    }

    #schedules-table tbody tr > .schedule-action-cell::before {
        display: none;
    }

    #schedules-table .schedule-actions {
        min-width: 0;
        width: 100%;
        flex-wrap: nowrap;
    }

    #schedules-table .schedule-detail-button {
        flex: 1 1 auto;
    }

    #schedules-table .schedule-action-menu {
        flex: 0 0 auto;
    }

    #schedules-table .schedule-action-menu > .dropdown-toggle {
        width: 2.5rem;
        padding-right: 0;
        padding-left: 0;
    }

    #schedules-table .schedule-note br {
        display: none;
    }

    .dt-container .dt-layout-row {
        align-items: stretch;
    }

    .dt-container .dt-layout-cell {
        flex: 1 1 100%;
        width: 100%;
    }

    .dt-container .dt-search,
    .dt-container .dt-search input {
        width: 100%;
    }

    .dt-container .dt-length select {
        width: auto;
    }

    .schedule-actions {
        min-width: 9rem;
    }

    .photo-work-item {
        width: calc(50vw - 2rem);
        max-width: 160px;
    }

    .photo-work-item .photo-preview-button,
    .photo-work-item .photo-preview-button img {
        width: 100%;
    }

    #camera-upload-form .d-flex.flex-wrap.gap-2 > .btn,
    #camera-upload-form .card-footer .btn {
        flex: 1 1 100%;
        width: 100%;
    }

    #photoViewerModal .modal-dialog {
        margin: 0.5rem;
    }

    #photoViewerModal .modal-header,
    #photoViewerModal .modal-footer {
        flex-wrap: wrap;
        gap: var(--app-space-2);
    }

    #photoViewerModal .modal-header .modal-title {
        flex: 1 1 100%;
    }

    #photoViewerModal .modal-header > .d-flex {
        width: 100%;
        justify-content: flex-end;
    }

    #photoViewerModal .modal-body img {
        max-height: 60vh !important;
    }

    #photoViewerModal .modal-footer > button,
    #photoViewerModal .modal-footer > span {
        flex: 1 1 auto;
    }

    #photoViewerModal .modal-footer {
        flex-wrap: nowrap;
        gap: var(--app-space-1);
        padding: var(--app-space-2);
        min-width: 0;
    }

    #photoViewerModal .modal-footer > button {
        flex: 1 1 0;
        min-width: 0;
        padding-left: var(--app-space-1);
        padding-right: var(--app-space-1);
        font-size: 0.8rem;
        white-space: nowrap;
    }

    #photoViewerModal .modal-footer > span {
        flex: 0 0 auto;
        white-space: nowrap;
        font-size: 0.8rem;
    }

    .schedule-actions {
        gap: var(--app-space-1);
    }
}
