/* Responsive workspace navigation */
.nav-shell {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-height: 4rem;
}

.brand-row {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.nav-menu {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-width: 0;
}

.nav-checkbox {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    padding: 10px;
    color: #e5e7eb;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-checkbox:focus-visible ~ .brand-row .nav-toggle,
.nav-link:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #60a5fa;
    outline-offset: 2px;
}

.user-panel {
    min-width: 0;
}

.user-panel .user-name {
    display: block;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-container {
    overflow-wrap: break-word;
}

.mobile-table-hint {
    display: none;
}

@media (max-width: 1279px) {
    .nav-shell {
        gap: 0.75rem;
    }

    .nav-links {
        gap: 0.8rem;
    }

    .user-panel .user-name {
        max-width: 170px;
    }
}

@media (max-width: 1023px) {
    .user-panel .user-position {
        display: none;
    }
}

@media (max-width: 767.98px) {
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        min-width: 320px;
        overflow-x: hidden;
        font-size: 16px;
    }

    .nav-shell {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 0 12px !important;
    }

    .brand-row {
        width: 100%;
        height: 56px;
        justify-content: space-between;
    }

    .brand-row .text-xl {
        margin-right: 0 !important;
        font-size: 1.1rem !important;
    }

    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .nav-menu {
        display: none;
        flex: none !important;
        width: 100%;
        height: auto !important;
        padding: 0 0 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .nav-checkbox:checked ~ .nav-menu {
        display: flex;
    }

    .nav-links {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }

    .nav-link,
    .nav-link.active,
    .nav-link.active.logs,
    .nav-link.active.admin {
        display: flex !important;
        align-items: center;
        min-height: 44px;
        padding: 10px 12px;
        border: 0;
        border-left: 3px solid transparent;
        border-radius: 6px;
        font-size: 0.95rem;
        text-decoration: none;
    }

    .nav-link::after {
        display: none;
    }

    .nav-link.active {
        color: #dbeafe;
        border-left-color: #60a5fa;
        background: #374151;
    }

    .nav-link.active.logs {
        color: #fde68a;
        border-left-color: #fbbf24;
    }

    .nav-link.active.admin {
        color: #fecaca;
        border-left-color: #f87171;
    }

    .user-panel {
        width: 100%;
        margin-top: 4px;
        padding: 10px 12px !important;
        justify-content: space-between;
        gap: 8px !important;
        border-radius: 8px !important;
    }

    .user-panel .user-name {
        max-width: 52vw;
    }

    .user-panel .user-position {
        display: none;
    }

    .main-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 16px 12px 32px !important;
        overflow-x: hidden;
        animation: none;
    }

    .main-container h1 {
        font-size: 1.55rem !important;
        line-height: 1.25 !important;
    }

    .main-container h2 {
        font-size: 1.25rem !important;
        line-height: 1.35 !important;
    }

    .main-container h3 {
        font-size: 1.05rem !important;
    }

    .main-container .p-6 {
        padding: 1rem !important;
    }

    .main-container .p-5 {
        padding: 1rem !important;
    }

    .main-container .mb-6 {
        margin-bottom: 1rem !important;
    }

    .main-container button,
    .main-container input[type="submit"],
    .main-container .btn {
        min-height: 42px;
    }

    .main-container input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
    .main-container select,
    .main-container textarea {
        max-width: 100%;
        min-height: 44px;
        box-sizing: border-box;
        font-size: 16px !important;
    }

    .main-container input[type="checkbox"],
    .main-container input[type="radio"] {
        width: 22px;
        height: 22px;
    }

    .main-container .flex.flex-wrap > button,
    .main-container .flex.flex-wrap > a,
    .main-container .flex.flex-wrap > form {
        max-width: 100%;
    }

    .main-container > .flex.flex-col.gap-4 > .flex.gap-2 {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px !important;
        padding: 6px !important;
    }

    .main-container > .flex.flex-col.gap-4 > .flex.gap-2 button {
        min-width: 0;
        padding: 8px 4px !important;
        font-size: 0.75rem !important;
        white-space: normal;
    }

    #employeesTab {
        width: 100%;
        flex-direction: column !important;
        gap: 16px !important;
    }

    .left-panel-container {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .left-panel {
        width: 100%;
        min-height: 0 !important;
        max-height: none !important;
    }

    #employeeList {
        min-height: 0 !important;
        max-height: 340px !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
    }

    .employee-item {
        min-height: 58px;
        padding: 10px 12px !important;
    }

    .employee-name {
        font-size: 0.95rem !important;
        line-height: 1.35 !important;
    }

    .employee-tab {
        font-size: 0.75rem !important;
    }

    .right-panel-stable {
        width: 100%;
        min-width: 0;
        min-height: 0 !important;
    }

    .content-wrapper {
        width: 100%;
        gap: 16px !important;
    }

    .table-scroll {
        max-width: 100%;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .main-container table.data-table,
    .main-container table.dataTable,
    .main-container .table-scroll table,
    .main-container .table-container table {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
        background: transparent !important;
    }

    .main-container table.data-table thead,
    .main-container table.dataTable thead,
    .main-container .table-scroll table thead,
    .main-container .table-container table thead {
        display: none;
    }

    .main-container table.data-table tbody,
    .main-container table.dataTable tbody,
    .main-container .table-scroll table tbody,
    .main-container .table-container table tbody {
        display: block;
        width: 100%;
    }

    .main-container table.data-table tbody tr,
    .main-container table.dataTable tbody tr,
    .main-container .table-scroll table tbody tr,
    .main-container .table-container table tbody tr {
        display: block;
        width: 100%;
        margin: 10px;
        padding: 10px 12px;
        box-sizing: border-box;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        background: #fff;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    }

    .main-container table.data-table tbody td,
    .main-container table.dataTable tbody td,
    .main-container .table-scroll table tbody td,
    .main-container .table-container table tbody td {
        display: grid;
        grid-template-columns: minmax(86px, 38%) minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        width: 100% !important;
        min-width: 0 !important;
        padding: 6px 0 !important;
        border: 0 !important;
        background: transparent !important;
        font-size: 0.86rem !important;
        line-height: 1.4 !important;
        text-align: left !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .main-container table.data-table tbody td::before,
    .main-container table.dataTable tbody td::before,
    .main-container .table-scroll table tbody td::before,
    .main-container .table-container table tbody td::before {
        content: attr(data-label);
        color: #6b7280;
        font-size: 0.7rem;
        font-weight: 600;
        line-height: 1.45;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    .main-container table.data-table tbody td[colspan],
    .main-container table.dataTable tbody td[colspan],
    .main-container .table-scroll table tbody td[colspan],
    .main-container .table-container table tbody td[colspan],
    .main-container table.dataTable tbody td.dataTables_empty {
        display: block;
        padding: 14px 4px !important;
        text-align: center !important;
    }

    .main-container table.data-table tbody td[colspan]::before,
    .main-container table.dataTable tbody td[colspan]::before,
    .main-container .table-scroll table tbody td[colspan]::before,
    .main-container .table-container table tbody td[colspan]::before,
    .main-container table.dataTable tbody td.dataTables_empty::before {
        content: none;
    }

    .main-container tbody td .flex {
        flex-wrap: wrap;
    }

    .main-container tbody td button,
    .main-container tbody td .btn {
        min-height: 36px;
    }

    .dataTables_wrapper {
        width: 100%;
        overflow: visible !important;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        width: 100%;
        margin: 0 0 12px !important;
        text-align: left !important;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin: 6px 0 0 !important;
        padding: 10px 12px;
        border: 1px solid #d1d5db;
        border-radius: 8px;
    }

    .dataTables_wrapper .dataTables_length select {
        min-height: 40px;
        margin: 0 6px;
    }

    .dataTables_wrapper .dataTables_info {
        float: none !important;
        padding: 10px 0 !important;
        font-size: 0.75rem;
        text-align: left;
    }

    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
        padding: 8px 0 !important;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        min-width: 36px;
        min-height: 36px;
        margin: 0 !important;
        padding: 8px !important;
        box-sizing: border-box;
    }

    .fixed.inset-0 {
        padding: 12px;
        box-sizing: border-box;
    }

    .fixed.inset-0 > .bg-white {
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100vh - 24px);
        margin: auto;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .fixed.inset-0 > .bg-white .grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .mobile-table-hint {
        display: block;
        margin: 0 0 8px;
        color: #6b7280;
        font-size: 0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
