/* ========================================
   DATA MANAGEMENT PORTAL - STYLES
   ======================================== */

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

body {
    font-family: var(--font-b);
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.55;
    padding: 24px;
}

/* ========================================
   NAVIGATION BAR - Unified Dark Theme
   ======================================== */

.nav-links {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-link.active {
    background: var(--ink);
    color: #fff;
}

.link-icon {
    font-size: 18px;
}

/* ========================================
   MAIN CONTAINER
   ======================================== */

.container {
    max-width: 1400px;
    margin: 26px auto 40px;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.97);
    border-radius: 20px;
    min-height: calc(100vh - 64px - 66px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

/* ========================================
   PAGE HEADER
   ======================================== */

.page-header {
    background: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: var(--ink);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-description {
    color: var(--ink-50);
    font-size: 0.95rem;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.filter-controls label {
    font-weight: 500;
    color: var(--ink-70);
}

.filter-select {
    border: 2px solid var(--line);
    border-radius: 6px;
    min-width: 200px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    }

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ========================================
   TABS
   ======================================== */

.tabs {
    display: flex;
    gap: 0;
    margin-top: 0;
    margin-bottom: 0;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: var(--line-soft);
    border: none;
    border-radius: 8px 8px 0 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink-70);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    border-right: 1px solid var(--primary-soft);
}

.tab-btn:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.tab-btn.active {
    background: var(--bg-soft);
    color: var(--primary);
    box-shadow: 0 4px 8px rgba(76, 111, 255, 0.18);
    position: relative;
    z-index: 2;
    border-right-color: transparent;
}

.tab-content {
    display: none;
}

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

.tab-btn.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: var(--bg-soft);
}

.tab-btn:last-child {
    border-right: none;
}

.tabs-wrapper {
    max-width: 1400px;
    margin: 26px auto 0;
    padding: 0;
}

.tabs-wrapper + .container {
    margin-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: 0;
}

/* ========================================
   TABLE CONTAINER
   ======================================== */

.table-container {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.table-header {
    padding: 1.5rem 2rem;
    background: var(--bg-soft);
    border-bottom: 2px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header h3 {
    color: var(--ink);
    font-size: 1.25rem;
}

.filter-search-group {
    display: flex;
    gap: 1rem;
    flex: 1;
    align-items: center;
    flex-wrap: wrap;
}

.filter-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-box label {
    font-weight: 600;
    color: var(--ink-70);
    white-space: nowrap;
}

.search-box {
    flex: 1;
    max-width: 400px;
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.selection-count {
    font-size: 0.85rem;
    color: var(--ink-50);
    min-width: 90px;
    text-align: right;
}

.bulk-actions button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.search-input {
    width: 100%;
    border: 2px solid var(--line);
    border-radius: 6px;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.table-wrapper {
    overflow-x: auto;
    max-height: 600px;
}

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

.data-table thead {
    background: var(--bg-soft);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--ink-70);
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
}

.select-column {
    width: 48px;
    text-align: center;
}

.select-column input[type="checkbox"] {
    width: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 2rem;
}

.data-table th.sortable:hover {
    background: var(--line-soft);
}

.data-table th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 0.75rem;
    opacity: 0.4;
    font-size: 0.9rem;
}

.data-table th.sort-asc::after {
    content: '↑';
    opacity: 1;
    color: var(--primary);
}

.data-table th.sort-desc::after {
    content: '↓';
    opacity: 1;
    color: var(--primary);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--line);
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
    background: var(--bg-soft);
}

.data-table td {
    padding: 1rem;
    color: var(--ink);
}

.loading-message,
.no-data {
    text-align: center;
    padding: 3rem !important;
    color: var(--ink-50);
    font-style: italic;
}

.location-cell {
    font-family: var(--font-m);
    font-size: 0.875rem;
}

.description-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.actions-cell {
    display: flex;
    gap: 0.5rem;
}

.table-footer {
    padding: 1rem 2rem;
    background: var(--bg-soft);
    border-top: 2px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-footer span {
    color: var(--ink-50);
    font-weight: 500;
}

/* ========================================
   BADGES
   ======================================== */

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-soil {
    background: var(--warn-soft);
    color: var(--warn);
}

.badge-water {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.badge-good {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.badge-moderate {
    background: var(--warn-soft);
    color: var(--warn);
}

.badge-poor {
    background: var(--warn-soft);
    color: var(--warn);
}

.data-table th.actions-column {
    width: 240px;
    text-align: center;
}

/* ========================================
   DETAILS MODAL SPECIFIC
   ======================================== */

.sample-details h3 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--line);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
}

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

.detail-label {
    font-weight: 600;
    color: var(--ink-70);
    min-width: 150px;
}

.detail-value {
    color: var(--ink);
    text-align: right;
    flex: 1;
}

.detail-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.detail-edit-btn {
    font-size: 1.1rem;
    line-height: 1;
}

.inactive-section {
    border: 1px dashed var(--line);
}

.inactive-row {
    background: var(--bg-soft);
    color: var(--ink-50);
}

/* ========================================
   MODALS
   ======================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-small {
    max-width: 450px;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--ink);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--ink-50);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--bg-soft);
    color: var(--ink);
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 2px solid var(--line);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* ========================================
   FORMS
   ======================================== */

form {
    padding: 2rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--ink-70);
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    border: 2px solid var(--line);
    border-radius: 6px;
    font-family: inherit;
    transition: border-color 0.2s ease;
    }

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    background-color: var(--surface);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group input[readonly] {
    background: var(--bg-soft);
    color: var(--ink-50);
    cursor: not-allowed;
}

.form-hint {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--ink-50);
}

.conditional-fields {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--line);
}

.conditional-fields h4 {
    color: var(--ink-70);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.alert-info {
    background: var(--primary-soft);
    border-left: 4px solid var(--primary);
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-info strong {
    color: var(--primary-dark);
}

.warning-text {
    color: var(--warn);
    font-weight: 500;
    margin-top: 0.5rem;
}

/* ========================================
   NOTIFICATIONS
   ======================================== */

.notification {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 3000;
    font-weight: 500;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s ease;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left: 4px solid var(--live);
    color: var(--primary-dark);
}

.notification-error {
    border-left: 4px solid var(--warn);
    color: var(--warn);
}

.notification-info {
    border-left: 4px solid var(--primary);
    color: var(--primary-dark);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 1024px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .filter-controls {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-select {
        width: 100%;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .search-box {
        width: 100%;
        max-width: none;
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1.25rem;
        margin: 16px 16px 24px;
        border-radius: 16px;
    }

    .tabs-wrapper + .container {
        margin-top: 0;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }

    .tabs-wrapper {
        margin: 16px 16px 0;
        padding: 0;
    }

    .tabs {
        flex-direction: column;
    }

    .page-header {
        padding: 1.25rem;
    }

    .page-header h2 {
        font-size: 1.5rem;
    }

    .nav-links {
        flex-direction: column;
        width: 100%;
    }

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

    .data-table {
        font-size: 0.875rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem;
    }

    .modal {
        padding: 0.5rem;
    }

    .modal-header {
        padding: 1rem 1.25rem;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .modal-footer {
        padding: 1rem 1.25rem;
    }

    .notification {
        top: auto;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
    }
}
