/* ============================================
   IWI Research Dashboard - Global Design Tokens
   Single Source of Truth for all colors.
   ============================================ */
:root {
    /* === IWI Brand Colors (from logo) === */
    --iwi-blue: #0052CC;
    --iwi-blue-dark: #00308F;
    --iwi-blue-light: #E6F0FF;
    --iwi-blue-rgb: 0, 82, 204;
    --iwi-red: #E63B2E;
    --iwi-red-light: #FEEEED;

    /* === Functional Status Colors === */
    --iwi-success: #0D9F6E;
    --iwi-success-light: #D1FAE5;
    --iwi-warning: #E8A317;
    --iwi-warning-light: #FEF3C7;
    --iwi-danger: #DC3545;
    --iwi-danger-light: #FEE2E2;

    /* === Neutral System === */
    --iwi-heading: #1A1F36;
    --iwi-text: #3D4663;
    --iwi-muted: #6B7A99;
    --iwi-border: #E2E8F0;
    --iwi-surface: #F8FAFC;
    --iwi-bg: #f8f9fa;

    /* === Spacing & Shape === */
    --iwi-radius: 8px;
    --iwi-radius-sm: 6px;
    --iwi-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --iwi-shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.08);
    --iwi-transition: 200ms ease;

    /* === Bootstrap Override (consumed globally) === */
    --bs-primary: var(--iwi-blue);
    --bs-primary-rgb: var(--iwi-blue-rgb);
    --bs-link-color: var(--iwi-blue);
    --bs-link-hover-color: var(--iwi-blue-dark);
}

/* Main application styles */

/* General styling */
body {
    font-family: 'Source Sans Pro', sans-serif;
    line-height: 1.6;
    color: var(--iwi-text);
    background-color: var(--iwi-bg);
    overflow-x: hidden;
}

/* Utility classes */
.cursor-pointer {
    cursor: pointer;
}

/* Container padding */
.container {
    padding-top: 20px;
    padding-bottom: 20px;
}

/* Card styling */
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    font-weight: 500;
}

/* Button styling */
.btn-primary {
    background-color: var(--iwi-blue);
    border-color: var(--iwi-blue);
}

.btn-primary:hover {
    background-color: var(--iwi-blue-dark);
    border-color: var(--iwi-blue-dark);
}

/* Table styling */
.table-responsive {
    overflow-x: auto;
}

.table th {
    background-color: #f8f9fa;
    border-top: none;
}

/* Modal styling */
.modal-header {
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

/* Search input styling */
.search-input {
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.search-input:focus {
    color: #495057;
    background-color: #fff;
    border-color: var(--iwi-blue);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(var(--iwi-blue-rgb), 0.2);
}

/* Selectable rows */
.selectable-row {
    cursor: pointer;
}

.selectable-row:hover {
    background-color: rgba(var(--iwi-blue-rgb), 0.08);
}

/* Selected item indicators */
.selected-item {
    background-color: var(--iwi-blue-light);
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    display: inline-block;
}

.selected-item .remove-item {
    margin-left: 0.5rem;
    cursor: pointer;
}

/* Categories container */
.selected-categories-container {
    margin-top: 0.5rem;
}

/* Responsive fixes */
@media (max-width: 767.98px) {
    .table-responsive {
        font-size: 0.875rem;
    }

    /* Prevent buttons from wrapping */
    .action-buttons {
        white-space: nowrap;
    }

    /* Make modal better on mobile */
    .modal-dialog {
        margin: 0.5rem;
    }

    /* Adjust font sizes for mobile */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .display-4 {
        font-size: 2rem;
    }

    .lead {
        font-size: 1rem;
    }

    /* Adjust padding for mobile */
    .card-body {
        padding: 1rem;
    }

    /* Make form elements more mobile-friendly */
    .form-control,
    .form-select,
    .btn {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        font-size: 0.9rem;
    }

    /* Adjust for smaller devices */
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* Extra small devices (phones) */
@media (max-width: 575.98px) {

    /* Further reduce sizes */
    .card-header h5 {
        font-size: 1rem;
    }

    /* Stack form inputs */
    .input-group {
        flex-wrap: wrap;
    }

    .input-group>* {
        width: 100%;
        margin-bottom: 0.5rem;
        border-radius: 0.25rem !important;
    }

    /* Better table display on very small screens */
    .table thead {
        display: none;
    }

    .table tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 0.25rem;
    }

    .table tbody td {
        display: block;
        text-align: right;
        position: relative;
        padding-left: 50%;
        white-space: normal;
    }

    .table tbody td:before {
        content: attr(data-label);
        position: absolute;
        left: 0.75rem;
        width: 45%;
        text-align: left;
        font-weight: bold;
    }

    /* Handle journal badges better */
    .journal-badges .badge {
        display: inline-block;
        margin-top: 0.25rem;
    }

    /* Pagination adjustments */
    .pagination .page-link {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
}

/* Prevent text overflow and add ellipsis for long content */
.text-truncate-custom {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}

/* Better responsive tables */
.table-responsive-stack tr {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
}

.table-responsive-stack td,
.table-responsive-stack th {
    display: block;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
}

/* Handle data table responsive display */
@media (max-width: 991.98px) {
    .dataTables_wrapper .row {
        margin-bottom: 1rem;
    }

    .dataTables_length,
    .dataTables_filter,
    .dataTables_info,
    .dataTables_paginate {
        text-align: left !important;
        margin-bottom: 0.5rem;
    }
}

/* Improve toast responsiveness */
@media (max-width: 575.98px) {
    .toast-container {
        right: 10px;
        left: 10px;
        width: auto;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }
}

/* Fix modals on small screens */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0;
        height: 100%;
        max-width: none;
    }

    .modal-content {
        height: 100%;
        border: 0;
        border-radius: 0;
    }

    .modal-body {
        overflow-y: auto;
    }
}