/**
 * TRIZ Principles Explorer - Custom Styles
 * Enhances Bootstrap 5 with custom styling for the TRIZ application
 */

/* ===== ROOT VARIABLES ===== */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    
    --border-radius: 0.375rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --box-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    
    --transition: all 0.3s ease;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ===== GLOBAL STYLES ===== */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--dark-color);
    background-color: #f5f7fa;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
}

.h4 {
    color: var(--primary-color);
}

/* ===== HEADER STYLES ===== */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-bottom: 3px solid var(--primary-color);
}

header h1 {
    color: white !important;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

header .btn {
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: 500;
    transition: var(--transition);
}

header .btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: white;
    transform: translateY(-1px);
}

/* ===== CARD STYLES ===== */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--box-shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-header.bg-light {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
}

.card-header.bg-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%) !important;
}

.card-body {
    padding: 1.5rem;
}

/* ===== FORM STYLES ===== */
.form-control, .form-select {
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    transition: var(--transition);
    font-size: 0.95rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    transform: translateY(-1px);
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.form-text {
    font-size: 0.85rem;
    color: var(--secondary-color);
}

/* ===== BUTTON STYLES ===== */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: var(--transition);
    border: 2px solid transparent;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    border-color: var(--primary-color);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #146c43 100%);
    border-color: var(--success-color);
}

.btn-outline-primary {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-success {
    border-color: var(--success-color);
    color: var(--success-color);
}

.btn-outline-success:hover {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-outline-danger {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.btn-outline-danger:hover {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

/* ===== SEARCH FUNCTIONALITY ===== */
/* ===== SEARCH SUGGESTIONS STYLES ===== */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: var(--primary-color)
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active {
    background-color: #3498db;
    color: white;
}

/* Ensure all text in hovered suggestion items is white */
.suggestion-item:hover *,
.suggestion-item.active * {
    color: white !important;
}

/* Main principle name styling */
.suggestion-item .principle-name {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
}

/* Additional descriptive text styling */
.suggestion-item .principle-description {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.3;
    margin-top: 0.25rem;
    opacity: 0.9;
}

/* When hovering, make descriptive text white */
.suggestion-item:hover .principle-description,
.suggestion-item.active .principle-description {
    color: white !important;
    opacity: 1;
}

/* Highlighted search terms */
.suggestion-item strong {
    font-weight: 700;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 0.1rem 0.2rem;
    border-radius: 0.2rem;
}

.suggestion-item:hover strong,
.suggestion-item.active strong {
    background-color: rgba(255, 255, 255, 0.3);
    color: white !important;
}

/* Principle ID styling */
.suggestion-item .principle-id {
    color: #3498db;
    font-weight: 600;
}

.suggestion-item:hover .principle-id,
.suggestion-item.active .principle-id {
    color: white !important;
}

/* No results message */
.search-suggestions .text-muted {
    color: #666 !important;
    font-style: italic;
}

/* Scrollbar styling for search results */
.search-suggestions::-webkit-scrollbar {
    width: 6px;
}

.search-suggestions::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.search-suggestions::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.search-suggestions::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Focus styles for accessibility */
.suggestion-item:focus {
    outline: 2px solid #3498db;
    outline-offset: -2px;
    background-color: #3498db;
    color: white;
}

.suggestion-item:focus *,
.suggestion-item:focus .principle-description {
    color: white !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .search-suggestions {
        max-height: 250px;
        font-size: 0.9rem;
    }
    
    .suggestion-item {
        padding: 0.6rem 0.8rem;
    }
    
    .suggestion-item .principle-name {
        font-size: 0.85rem;
    }
    
    .suggestion-item .principle-description {
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    .search-suggestions {
        max-height: 200px;
        font-size: 0.85rem;
    }
    
    .suggestion-item {
        padding: 0.5rem 0.7rem;
    }
    
    .suggestion-item .principle-name {
        font-size: 0.8rem;
    }
    
    .suggestion-item .principle-description {
        font-size: 0.7rem;
        margin-top: 0.2rem;
    }
}

/* Animation for smooth appearance */
.search-suggestions {
    animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure search input container has relative positioning */
.mb-3:has(#principle-search) {
    position: relative;
}

/* Alternative selector for older browsers */
#principle-search {
    position: relative;
}

#principle-search + .search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
}

/* Search input focus state */
#principle-search:focus + .search-suggestions {
    border-color: var(--primary-color);
}

/* Empty search results */
.search-suggestions .no-results {
    padding: 1rem;
    text-align: center;
    color: var(--secondary-color);
    font-style: italic;
}

/* Search highlighting */
.search-highlight {
    background-color: #cc871f;
    color: #856404;
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    font-weight: 600;
}

/* Mobile responsive search */
@media (max-width: 575.98px) {
    .search-suggestions {
        font-size: 0.85rem;
        max-height: 250px;
    }
    
    .suggestion-item {
        padding: 0.5rem 0.75rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .suggestion-item .principle-number {
        min-width: auto;
    }
}

/* ===== CATEGORY FILTERS ===== */
.category-filter {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    transition: var(--transition);
}

.category-filter.active {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

/* ===== PRINCIPLE CONTENT ===== */
.principle-description {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
}

.principle-examples {
    margin-bottom: 1.5rem;
}

.principle-examples h5 {
    color: var(--success-color);
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
}

.principle-examples h5::before {
    content: "💡";
    margin-right: 0.5rem;
    font-size: 1.2em;
}

.principle-examples ul {
    list-style: none;
    padding-left: 0;
}

.principle-examples li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    border-bottom: 1px solid #f0f0f0;
    transition: var(--transition);
}

.principle-examples li:last-child {
    border-bottom: none;
}

.principle-examples li::before {
    content: "▶";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.principle-examples li:hover {
    background-color: rgba(13, 110, 253, 0.05);
    padding-left: 1.75rem;
}

/* ===== RELATED PRINCIPLES ===== */
.related-principles {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 2px solid #e9ecef;
}

.related-principles h5 {
    color: var(--info-color);
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.related-principles h5::before {
    content: "🔗";
    margin-right: 0.5rem;
    font-size: 1.2em;
}

.related-principles .card {
    border: 2px solid #e9ecef;
    transition: var(--transition);
}

.related-principles .card:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
}

.related-principles .card-title {
    color: var(--primary-color);
    font-weight: 600;
}

/* ===== COMPARISON STYLES ===== */
#comparison-container {
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comparison-table {
    font-size: 0.9rem;
}

.comparison-table th {
    background: linear-gradient(135deg, var(--success-color) 0%, #146c43 100%);
    color: white;
    font-weight: 600;
    text-align: center;
    padding: 1rem;
}

.comparison-table td {
    vertical-align: top;
    padding: 1rem;
    border: 2px solid #e9ecef;
}

.comparison-table .badge {
    font-size: 1rem;
    padding: 0.5rem;
}

.remove-from-compare {
    opacity: 0.7;
    transition: var(--transition);
}

.remove-from-compare:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* ===== BACK TO TOP BUTTON ===== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--box-shadow-lg);
    transition: var(--transition);
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* ===== LOADING SPINNER ===== */
#loading-spinner {
    padding: 3rem 0;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* ===== ALERTS AND NOTIFICATIONS ===== */
.alert {
    border: none;
    border-radius: var(--border-radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border-left-color: var(--info-color);
    color: #0c5460;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-left-color: var(--warning-color);
    color: #856404;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-left-color: var(--success-color);
    color: #155724;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-left-color: var(--danger-color);
    color: #721c24;
}

/* ===== NOTIFICATION CONTAINER ===== */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
}

#notification-container .alert {
    margin-bottom: 0.5rem;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== MODAL STYLES ===== */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    color: white;
    border-bottom: none;
}

.modal-title {
    font-weight: 600;
}

.btn-close {
    filter: invert(1);
}

/* Dark background for TRIZ introduction modal */
#aboutModal .modal-content {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #ecf0f1;
    border: 2px solid #34495e;
}

#aboutModal .modal-header {
    background: linear-gradient(135deg, #1a252f 0%, #2c3e50 100%);
    color: #ecf0f1;
    border-bottom: 2px solid #34495e;
}

#aboutModal .modal-body {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #ecf0f1;
}

#aboutModal .modal-body h5 {
    color: #3498db;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #34495e;
    padding-bottom: 0.5rem;
}

#aboutModal .modal-body h5:first-child {
    margin-top: 0;
}

#aboutModal .modal-body p {
    color: #bdc3c7;
    line-height: 1.6;
    margin-bottom: 1rem;
}

#aboutModal .modal-body ul {
    color: #bdc3c7;
}

#aboutModal .modal-body li {
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

#aboutModal .modal-body li::marker {
    color: #3498db;
}

#aboutModal .modal-footer {
    background: linear-gradient(135deg, #1a252f 0%, #2c3e50 100%);
    border-top: 2px solid #34495e;
}

#aboutModal .btn-secondary {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    border-color: #7f8c8d;
    color: #2c3e50;
    font-weight: 600;
}

#aboutModal .btn-secondary:hover {
    background: linear-gradient(135deg, #7f8c8d 0%, #95a5a6 100%);
    border-color: #95a5a6;
    color: #1a252f;
    transform: translateY(-1px);
}

#aboutModal .btn-close {
    filter: invert(1);
    opacity: 0.8;
}

#aboutModal .btn-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Add subtle animation for modal appearance */
#aboutModal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translate(0, -50px);
}

#aboutModal.show .modal-dialog {
    transform: translate(0, 0);
}

/* Enhance readability with better contrast */
#aboutModal .modal-body strong {
    color: #e74c3c;
    font-weight: 600;
}

/* Style for any code or technical terms */
#aboutModal .modal-body code {
    background-color: #1a252f;
    color: #e67e22;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

/* Responsive adjustments for dark modal */
@media (max-width: 575.98px) {
    #aboutModal .modal-body {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    #aboutModal .modal-body h5 {
        font-size: 1.1rem;
        margin-top: 1rem;
    }
    
    #aboutModal .modal-body p,
    #aboutModal .modal-body li {
        font-size: 0.85rem;
    }
}

/* ===== SKIP LINK ===== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 9999;
    transition: top 0.3s ease;
    border-radius: 0 0 var(--border-radius) 0;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
    color: white;
    text-decoration: none;
}

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

/* Large screens (desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    .card-body {
        padding: 2rem;
    }
    
    .principle-description {
        padding: 1.5rem;
    }
}

/* Medium screens (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .card-body {
        padding: 1.25rem;
    }
    
    .btn-group .btn {
        font-size: 0.8rem;
        padding: 0.375rem 0.75rem;
    }
    
    .comparison-table {
        font-size: 0.85rem;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 0.75rem;
    }
}

/* Small screens (phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    header h1 {
        font-size: 1.25rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: var(--border-radius) !important;
        margin-bottom: 0.25rem;
    }
    
    .principle-examples li {
        font-size: 0.9rem;
        padding: 0.4rem 0;
        padding-left: 1.25rem;
    }
    
    .related-principles .col-md-6 {
        margin-bottom: 1rem;
    }
    
    .comparison-table {
        font-size: 0.8rem;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 0.5rem;
    }
    
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: 20px;
        right: 20px;
        font-size: 1rem;
    }
}

/* Extra small screens (phones, less than 576px) */
@media (max-width: 575.98px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    header {
        padding: 0.75rem 0;
    }
    
    header h1 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    header .d-flex {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    header .btn {
        font-size: 0.8rem;
        padding: 0.5rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .card-header {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .form-control,
    .form-select {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
    
    .btn {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: var(--border-radius) !important;
        margin-bottom: 0.25rem;
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
    
    .principle-description {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .principle-examples li {
        font-size: 0.85rem;
        padding: 0.35rem 0;
        padding-left: 1rem;
    }
    
    .related-principles {
        padding: 1rem;
    }
    
    .related-principles .card-body {
        padding: 0.75rem;
    }
    
    .related-principles .card-title {
        font-size: 0.9rem;
    }
    
    .related-principles .card-text {
        font-size: 0.8rem;
    }
    
    .related-principles .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Comparison table for mobile */
    .comparison-table {
        font-size: 0.75rem;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 0.4rem;
    }
    
    .comparison-table .badge {
        font-size: 0.7rem;
        padding: 0.25rem;
    }
    
    /* Stack comparison table vertically on very small screens */
    .table-responsive {
        border: none;
    }
    
    .comparison-table,
    .comparison-table thead,
    .comparison-table tbody,
    .comparison-table th,
    .comparison-table td,
    .comparison-table tr {
        display: block;
    }
    
    .comparison-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .comparison-table tr {
        border: 2px solid #e9ecef;
        margin-bottom: 1rem;
        border-radius: var(--border-radius);
        padding: 0.5rem;
    }
    
    .comparison-table td {
        border: none;
        position: relative;
        padding: 0.5rem 0.5rem 0.5rem 30%;
        text-align: left;
    }
    
    .comparison-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        width: 25%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        color: var(--primary-color);
    }
    
    .back-to-top {
        width: 40px;
        height: 40px;
        bottom: 15px;
        right: 15px;
        font-size: 0.9rem;
    }
    
    .search-suggestions {
        font-size: 0.85rem;
    }
    
    .suggestion-item {
        padding: 0.5rem 0.75rem;
    }
    
    #notification-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-body {
        padding: 1rem;
        font-size: 0.9rem;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .no-print,
    header,
    .back-to-top,
    #notification-container,
    .btn,
    .form-control,
    .form-select,
    .search-suggestions {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .card {
        border: 1px solid #ccc;
        box-shadow: none;
        page-break-inside: avoid;
        margin-bottom: 1rem;
    }
    
    .card-header {
        background: #f5f5f5 !important;
        color: black !important;
        border-bottom: 1px solid #ccc;
    }
    
    .principle-description {
        background: #f9f9f9 !important;
        border: 1px solid #ddd;
    }
    
    .comparison-table {
        border-collapse: collapse;
        width: 100%;
    }
    
    .comparison-table th,
    .comparison-table td {
        border: 1px solid #000;
        padding: 0.5rem;
    }
    
    .comparison-table th {
        background: #f0f0f0 !important;
        color: black !important;
    }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --success-color: #008000;
        --danger-color: #ff0000;
        --warning-color: #ff8c00;
    }
    
    .card {
        border: 2px solid #000;
    }
    
    .btn {
        border-width: 3px;
    }
    
    .form-control,
    .form-select {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .back-to-top,
    .card,
    .btn,
    .form-control,
    .form-select {
        transition: none;
    }
}

/* Focus indicators for keyboard navigation */
*:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* ===== UTILITY CLASSES ===== */

/* Text utilities */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

/* Animation utilities */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Spacing utilities */
.spacing-sm { margin: 0.5rem; }
.spacing-md { margin: 1rem; }
.spacing-lg { margin: 1.5rem; }
.spacing-xl { margin: 2rem; }

/* Border utilities */
.border-gradient {
    border: 2px solid;
    border-image: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%) 1;
}

/* Shadow utilities */
.shadow-custom {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.shadow-custom-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ===== DARK MODE SUPPORT (Future Enhancement) ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --dark-color: #ffffff;
        --light-color: #1a1a1a;
    }
    
    body {
        background-color: #121212;
        color: #ffffff;
    }
    
    .card {
        background-color: #1e1e1e;
        color: #ffffff;
    }
    
    .card-header.bg-light {
        background: linear-gradient(135deg, #2a2a2a 0%, #3a3a3a 100%) !important;
        color: #ffffff;
    }
    
    .form-control,
    .form-select {
        background-color: #2a2a2a;
        border-color: #404040;
        color: #ffffff;
    }
    
    .form-control:focus,
    .form-select:focus {
        background-color: #2a2a2a;
        border-color: var(--primary-color);
        color: #ffffff;
    }
    
    .principle-description {
        background: linear-gradient(135deg, #2a2a2a 0%, #3a3a3a 100%);
        color: #ffffff;
    }
    
    .related-principles {
        background: linear-gradient(135deg, #1e1e1e 0%, #2a2a2a 100%);
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* GPU acceleration for animations */
.card,
.btn,
.back-to-top {
    will-change: transform;
    transform: translateZ(0);
}

/* Optimize font loading */
.font-display-swap {
    font-display: swap;
}

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) #f1f1f1;
}

/* ===== TRIZ TABLE BUTTONS STYLES ===== */
.triz-table-btn {
    border-color: #ffc107 !important;
    color: #ffc107 !important;
    background-color: transparent !important;
    text-decoration: none !important;
    transition: all 0.3s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    border-width: 2px;
    border-style: solid;
}

/* Ensure link styles don't override button styles */
a.triz-table-btn {
    border-color: #ffc107 !important;
    color: #ffc107 !important;
    background-color: transparent !important;
    text-decoration: none !important;
}

a.triz-table-btn:link,
a.triz-table-btn:visited {
    border-color: #ffc107 !important;
    color: #ffc107 !important;
    background-color: transparent !important;
    text-decoration: none !important;
}

.triz-table-btn:hover,
a.triz-table-btn:hover {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #212529 !important;
    text-decoration: none !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.3);
}

.triz-table-btn:active,
a.triz-table-btn:active {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #212529 !important;
    transform: translateY(0);
}

.triz-table-btn:focus,
a.triz-table-btn:focus {
    background-color: transparent !important;
    border-color: #ffc107 !important;
    color: #ffc107 !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.5) !important;
    outline: none !important;
    text-decoration: none !important;
}

/* Override Bootstrap's btn-outline-warning styles specifically */
.btn.btn-outline-warning.triz-table-btn {
    border-color: #ffc107 !important;
    color: #ffc107 !important;
    background-color: transparent !important;
}

.btn.btn-outline-warning.triz-table-btn:hover {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #212529 !important;
}

.btn.btn-outline-warning.triz-table-btn:focus {
    background-color: transparent !important;
    border-color: #ffc107 !important;
    color: #ffc107 !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.5) !important;
}

.btn.btn-outline-warning.triz-table-btn:active {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #212529 !important;
}

/* Icon styling */
.triz-table-btn i.fa-table {
    transition: transform 0.3s ease;
    color: inherit;
}

.triz-table-btn:hover i.fa-table {
    transform: scale(1.1);
    color: inherit;
}

.triz-table-btn i.fa-external-link-alt {
    opacity: 0.7;
    transition: opacity 0.3s ease;
    color: inherit;
}

.triz-table-btn:hover i.fa-external-link-alt {
    opacity: 1;
    color: inherit;
}

/* Additional styling for better visual hierarchy */
.triz-table-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: inherit;
}

.triz-table-btn:hover::before {
    opacity: 1;
}

/* Focus styles for accessibility */
.triz-table-btn:focus-visible {
    outline: 2px solid #ffc107 !important;
    outline-offset: 2px;
}

/* Ensure proper color inheritance for all child elements */
.triz-table-btn * {
    color: inherit !important;
}

/* Override any potential Bootstrap color utilities */
.triz-table-btn.text-warning {
    color: #ffc107 !important;
}

.triz-table-btn.border-warning {
    border-color: #ffc107 !important;
}

/* Responsive adjustments for header buttons */
@media (max-width: 1200px) {
    .triz-table-btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.4rem;
    }
    
    .triz-table-btn i.fa-external-link-alt {
        display: none; /* Hide external link icon on smaller screens to save space */
    }
}

@media (max-width: 992px) {
    .d-flex.gap-2 {
        flex-wrap: wrap;
        gap: 0.25rem !important;
    }
    
    .triz-table-btn {
        font-size: 0.7rem;
        padding: 0.2rem 0.35rem;
    }
}

@media (max-width: 768px) {
    .d-flex.gap-2 {
        flex-wrap: wrap;
        gap: 0.5rem !important;
        justify-content: center;
    }
    
    .triz-table-btn {
        font-size: 0.65rem;
        padding: 0.2rem 0.3rem;
        min-width: 80px;
    }
}

@media (max-width: 576px) {
    .container .d-flex.justify-content-between {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .h4.mb-0 {
        text-align: center;
        margin-bottom: 0 !important;
        font-size: 1rem;
    }
    
    .d-flex.gap-2 {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
    
    .triz-table-btn {
        min-width: 70px;
        max-width: 90px;
        font-size: 0.6rem;
        padding: 0.25rem 0.2rem;
        text-align: center;
    }
    
    /* Compare buttons */
    #compare-button,
    #clear-comparison {
        min-width: 80px;
        font-size: 0.6rem;
        padding: 0.25rem 0.3rem;
    }
    
    /* About button */
    .btn-outline-primary {
        min-width: 100px;
        font-size: 0.6rem;
        padding: 0.25rem 0.3rem;
    }
}

@media (max-width: 480px) {
    .triz-table-btn {
        font-size: 0.55rem;
        padding: 0.2rem 0.15rem;
        min-width: 60px;
        max-width: 75px;
        line-height: 1.2;
    }
    
    #compare-button,
    #clear-comparison {
        font-size: 0.55rem;
        padding: 0.2rem 0.2rem;
        min-width: 65px;
    }
    
    .btn-outline-primary {
        font-size: 0.55rem;
        padding: 0.2rem 0.2rem;
        min-width: 80px;
    }
}

/* Ensure proper spacing in header */
header .container .d-flex.gap-2 > * {
    white-space: nowrap;
}

/* Special handling for very small screens - stack vertically */
@media (max-width: 400px) {
    .d-flex.gap-2 {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem !important;
    }
    
    .triz-table-btn,
    #compare-button,
    #clear-comparison,
    .btn-outline-primary {
        max-width: none;
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
        min-width: auto;
    }
}

/* Reduce horizontal gutters and increase container max-width on larger screens */
@media (min-width: 992px) {
  .container {
    max-width: 1340px;     /* use more horizontal space on desktop */
    padding-left: 12px;    /* reduce default Bootstrap side padding */
    padding-right: 12px;
  }
}

/* Ensure header and other container usages match reduced gutters */
header .container {
  padding-left: 12px;
  padding-right: 12px;
}

/* Remove any default body margin to avoid extra horizontal space */
body {
  margin: 0;
}

/* Remove any grouping-specific styles */
.triz-table-btn + .triz-table-btn {
    margin-left: 0; /* Remove any special spacing between TRIZ buttons */
}

/* Ensure each button behaves independently */
.triz-table-btn {
    flex: none; /* Don't grow or shrink based on siblings */
}

/* Debug styles - remove after confirming colors work */
/*
.triz-table-btn {
    background-color: red !important;
    border: 3px solid blue !important;
    color: white !important;
}
*/

/* ===== END OF STYLES ===== */