/* style.css */
:root {
    --primary-color: #007a72;
    /* Deeper, more saturated teal */
    --primary-light: #f0fdfa;
    --sidebar-bg: #f8fafc;
    --bg-color: #f1f5f9;
    /* Cleaner, slightly cooler gray */
    --text-main: #0f172a;
    /* Darker, higher contrast text */
    --text-muted: #475569;
    /* Mid-tone slate for better visibility */
    --text-light: #94a3b8;
    --border-color: #cbd5e1;
    /* More defined borders */
    --white: #ffffff;

    /* Font */
    --font-family: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    color: var(--text-main);
    background-color: var(--bg-color);
    font-size: 14px;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 250px;
    background-color: var(--primary-color);
    border-right: none;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.logo-container {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    gap: 12px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    clip-path: polygon(0 25%, 50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%);
    margin-right: 12px;
}

.logo-text {
    font-size: 16px;
    letter-spacing: -0.5px;
}

.logo-bold {
    font-weight: 700;
    color: #ffffff;
}

.logo-light {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-nav {
    padding: 24px 0;
    overflow-y: auto;
    flex: 1;
}

.nav-group {
    margin-bottom: 24px;
}

.nav-section-title {
    display: flex;
    align-items: center;
    padding: 0 24px;
    margin-bottom: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-section-title ion-icon {
    font-size: 18px;
}

.nav-items {
    list-style: none;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-item a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px 10px 48px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    transition: all 0.2s;
}

.nav-item a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.nav-item.active a {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-weight: 600;
    border-right: 4px solid #ffffff;
}

.badge {
    background-color: #f1f5f9;
    color: var(--text-main);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.active-badge {
    background-color: var(--primary-color);
    color: var(--white);
}

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --- HEADER --- */
.header {
    height: 60px;
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 5;
}

.top-nav ul {
    display: flex;
    list-style: none;
    gap: 32px;
    height: 60px;
}

.top-nav li {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.top-nav li:hover {
    color: white;
}

.top-nav li.active {
    color: white;
}

.top-nav li.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: white;
    border-radius: 4px 4px 0 0;
    box-shadow: 0 -2px 8px rgba(255, 255, 255, 0.4);
}

.header-badge {
    background-color: #cbd5e1;
    color: var(--text-main);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

#badgeAll {
    background-color: #3b82f6;
    color: white;
}

#badgePending {
    background-color: #f59e0b;
    color: white;
}

#badgeApproved {
    background-color: #10b981;
    color: white;
}

.top-nav li.active .header-badge {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 32px;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar input {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 32px 8px 12px;
    font-size: 13px;
    width: 200px;
    outline: none;
    transition: width 0.3s, border-color 0.2s;
}

.search-bar input:focus {
    width: 250px;
    border-color: var(--primary-color);
}

.search-clear {
    position: absolute;
    right: 10px;
    color: var(--text-muted);
    cursor: pointer;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.user-info {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    color: #ffffff;
}

.lang-selector {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--white);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* --- PAGE CONTENT --- */
.page-content {
    flex: 1;
    padding: 24px;
    overflow: hidden;
    /* Prevent page-level scrolling; only the table body will scroll */
    display: flex;
    flex-direction: column;
    position: relative;
}

.content-wrapper {
    background-color: var(--white);
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    /* Crucial for allowing nested flex children to scroll */
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--white);
    z-index: 20;
    flex-shrink: 0;
    /* Ensure tabs don't shrink */
}

.tabs {
    display: flex;
    gap: 24px;
}

.tab {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    padding-bottom: 8px;
    transition: color 0.2s;
}

.tab:hover {
    color: var(--text-main);
}

.tab.active {
    color: var(--primary-color);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -17px;
    /* Align with border-bottom of table-header */
    left: 0;
    width: 100%;
    height: 4px;
    /* Slightly thicker */
    background-color: var(--primary-color);
    border-radius: 4px 4px 0 0;
    box-shadow: 0 -2px 8px rgba(0, 122, 114, 0.4);
}

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon {
    background-color: transparent;
    color: var(--text-muted);
    font-size: 18px;
    padding: 8px;
}

.btn-icon:hover {
    color: var(--primary-color);
    background-color: var(--primary-light);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background-color: var(--primary-light);
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
    box-shadow: 0 2px 4px rgba(0, 137, 128, 0.2);
}

.btn-primary:hover {
    background-color: #007a72;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-danger {
    background-color: #fef2f2;
    color: #ef4444;
    border: 1px solid #fee2e2;
}

.btn-danger:hover {
    background-color: #fee2e2;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--primary-color);
    padding: 4px 8px;
}

.btn-text:hover {
    text-decoration: underline;
}

/* --- TABLE --- */
.table-container {
    flex: 1;
    overflow: auto;
    /* Enable scrolling specifically here */
    background: #fff;
    border-radius: 0 0 8px 8px;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: separate;
    /* Needed for reliable position: sticky on th */
    border-spacing: 0;
    text-align: left;
}

th {
    color: #475569;
    font-weight: 600;
    font-size: 13px;
    background-color: #f1f5f9;
    position: sticky;
    top: 0;
    /* Stick to top of .table-container */
    z-index: 10;
    border-bottom: 2px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    white-space: nowrap;
    padding: 16px 24px;
}

td {
    font-size: 14px;
    color: var(--text-main);
    vertical-align: middle;
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
}

tr:nth-child(even) {
    background-color: #f9fafb;
}

tr {
    transition: background-color 0.2s ease;
}

tr:hover {
    background-color: #f3f4f6 !important;
}

.doc-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.doc-link:hover {
    text-decoration: underline;
}

.requestor {
    display: flex;
    flex-direction: column;
}

.req-name {
    font-weight: 500;
}

.req-role {
    font-size: 11px;
    color: var(--text-muted);
}

.status-badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.status-badge[data-status="Очікує"] {
    background-color: #fff7ed;
    color: #c2410c;
    border: 1px solid #ffedd5;
}

.status-badge[data-status="Підтверджено"] {
    background-color: #f0fdf4;
    color: #15803d;
    border: 1px solid #dcfce7;
}

.status-badge[data-status="Протерміновано"] {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fee2e2;
}

/* --- PAGINATION --- */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
}

.pagination {
    display: flex;
    gap: 4px;
}

.page-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background-color: var(--white);
    color: var(--text-main);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.page-btn:hover:not(.disabled) {
    background-color: #f1f5f9;
}

.page-btn.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 600;
}

.page-btn.disabled {
    color: var(--text-light);
    cursor: default;
}

/* --- MODAL STYLES --- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: modalFadeIn 0.3s ease-out;
    overflow: hidden;
}

@keyframes modalFadeIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 24px;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.close-modal {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: opacity 0.2s;
}

.close-modal:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.detail-header-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
    font-size: 14px;
    color: var(--text-main);
}

.detail-items-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-items-table th {
    text-align: left;
    padding: 12px;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-size: 13px;
    color: var(--text-muted);
}

.detail-items-table td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
}

.detail-items-table th:first-child,
.detail-items-table td:first-child {
    width: 40px;
    text-align: center;
}

.modal-footer-info {
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}


.confirm-btn {
    background: #22c55e;
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.confirm-btn:hover:not(:disabled) {
    background: #16a34a;
}

.confirm-btn:disabled {
    background: #d1fae5;
    color: #065f46;
    cursor: default;
    opacity: 0.8;
}

.total-summary {
    font-size: 18px;
    color: var(--primary-color);
}

.responsible-person {
    font-size: 14px;
    font-style: italic;
    color: var(--text-muted);
}

.date-picker-input {
    border: 1px solid var(--border-color);
    padding: 0 12px;
    height: 38px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}

.date-picker-input:hover {
    border-color: var(--primary-color);
}

.date-picker-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.search-table-input {
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-main);
    outline: none;
    cursor: text;
    transition: all 0.2s;
    min-width: 260px;
    height: 38px;
}

.search-table-input::placeholder {
    color: var(--text-light);
}

.search-table-input:hover {
    border-color: var(--primary-color);
}

.search-table-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* --- MOBILE ADAPTATION --- */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.show {
    display: block;
    opacity: 1;
}

.header-mobile-left {
    display: none;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon-small {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    clip-path: polygon(0 25%, 50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%);
}

@media (max-width: 1024px) {
    .top-nav ul {
        gap: 16px;
    }

    .search-bar input {
        width: 150px;
    }
}

@media (max-width: 768px) {

    /* Sidebar becomes off-canvas */
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        width: 260px;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 50;
        border-right: none;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        left: 0;
    }

    /* Header adjustments */
    .header {
        padding: 0 16px;
        justify-content: space-between;
    }

    .header-mobile-left {
        display: flex;
    }

    .top-nav {
        display: none;
    }

    .header-actions {
        display: none;
    }

    .user-info {
        display: none;
    }

    .page-content {
        padding: 16px;
    }

    .table-header {
        display: none;
    }

    .actions {
        width: 100%;
        justify-content: stretch;
    }

    .btn {
        flex: 1;
        padding: 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    .tabs {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    th,
    td {
        padding: 12px 16px;
    }

    .pagination-container {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }
}