/* Custom Bootstrap Optimization CSS */

:root {
    --primary-gradient: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    --success-gradient: linear-gradient(135deg, #198754 0%, #157347 100%);
    --danger-gradient: linear-gradient(135deg, #dc3545 0%, #bb2d3b 100%);
    --warning-gradient: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    --info-gradient: linear-gradient(135deg, #0dcaf0 0%, #0b6db6 100%);
}

/* Typography */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: #f8f9fa;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* Navbar Enhancement */
.navbar {
    background: white;
    border-bottom: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.navbar-brand {
    transition: transform 0.2s ease;
}

.navbar-brand:hover {
    transform: scale(1.05);
}

.navbar-nav .nav-link {
    color: #495057 !important;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
}

.navbar-nav .nav-link:hover {
    color: #0d6efd !important;
    padding-left: calc(0.5rem + 4px) !important;
}

.navbar-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #0d6efd, transparent);
    transition: width 0.3s ease;
}

.navbar-nav .nav-link:hover::after {
    width: 100%;
}

/* Button Styles */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.btn-success {
    background: var(--success-gradient);
    border: none;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(25, 135, 84, 0.2);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(25, 135, 84, 0.3);
}

.btn-outline-primary {
    color: #0d6efd;
    border-color: #0d6efd;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-outline-primary:hover {
    background: var(--primary-gradient);
    border-color: transparent;
    transform: translateY(-2px);
}

.btn-outline-secondary {
    color: #6c757d;
    border-color: #dee2e6;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-outline-secondary:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
    transform: translateY(-2px);
}

.btn-sm {
    font-size: 0.875rem;
    padding: 0.4rem 0.8rem;
}

/* Card Styles */
.card {
    border: none;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-body {
    background: white;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.news-item {
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
}

.news-item:hover {
    border-left-color: #0d6efd;
}

/* Badge Styles */
.badge {
    font-weight: 500;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    transition: all 0.2s ease;
}

.badge:hover {
    transform: scale(1.05);
}

.bg-light.text-dark {
    background-color: #e9ecef !important;
}

.bg-primary-light {
    background-color: #cfe2ff !important;
}

.text-primary {
    color: #0d6efd !important;
}

/* Form Controls */
.form-control,
.form-select {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-label {
    color: #212529;
    margin-bottom: 0.5rem;
}

.form-text {
    color: #6c757d;
    font-size: 0.85rem;
}

.form-range {
    height: 0.5rem;
}

.form-range::-webkit-slider-thumb {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Progress Bar */
.progress {
    background-color: #e9ecef;
    border-radius: 0.375rem;
    overflow: hidden;
}

.progress-bar {
    background: var(--primary-gradient);
    transition: width 0.6s ease;
}

/* Spinner */
.spinner-border {
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* Alerts */
.alert {
    border: none;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

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

.modal-content {
    border: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border-radius: 0.375rem;
}

.btn-close {
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.btn-close:hover {
    opacity: 1;
}

/* Spacing Utilities */
.transition {
    transition: all 0.3s ease;
}

/* Empty State */
.display-1 {
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

/* Responsive Adjustments */
@media (max-width: 576px) {
    .navbar {
        padding: 0.5rem 0;
    }
    
    .navbar-brand {
        padding: 0.25rem !important;
    }
    
    .card-body {
        padding: 1rem !important;
    }
    
    .btn-sm {
        font-size: 0.8125rem;
        padding: 0.35rem 0.6rem;
    }
}

/* Utility Enhancements */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shadow-sm:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08) !important;
}

/* Links */
a {
    transition: color 0.3s ease;
}

a:hover {
    text-decoration: none;
}

/* Theme Toggle Button */
#theme-toggle {
    border-radius: 0.25rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

#theme-toggle:hover {
    background-color: #e9ecef;
    transform: rotate(20deg);
}

/* Dropdown Menu Polish */
.dropdown-menu {
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 0.375rem;
}

.dropdown-item {
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
    padding-left: 1.75rem;
}

/* Input Group */
.input-group {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border-radius: 0.375rem;
    overflow: hidden;
}

.input-group .form-control {
    border-right: none;
}

/* Container */
.container,
.container-fluid {
    max-width: 100%;
}

/* Link Button */
.btn-link {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-link:hover {
    color: #0b5ed7;
    text-decoration: underline;
}

/* Enhancement for w-auto on responsive */
@media (max-width: 576px) {
    .w-sm-auto {
        width: auto !important;
    }
}

/* Enhanced card borders and shadows */
.card {
    border-radius: 0.5rem;
}

.news-item {
    background: white;
    overflow: hidden;
}

/* Better spacing for small screens */
@media (max-width: 576px) {
    .container,
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* Better hover effects for links inside cards */
.card a {
    transition: color 0.3s ease;
}

.card a:hover {
    text-decoration: none;
}

/* Better alignment for badges */
.badge {
    display: inline-flex;
    align-items: center;
}

/* Enhanced form styling */
.form-control:disabled,
.form-select:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* Better pagination styling if needed */
.pagination .page-link {
    transition: all 0.3s ease;
}

.pagination .page-link:hover {
    transform: translateY(-1px);
}

/* Better modal backdrop and animations */
.modal-backdrop {
    animation: fadeIn 0.3s ease;
}

.modal.show {
    animation: slideUp 0.3s ease;
}

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

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

/* Enhanced text utilities */
.text-decoration-none {
    transition: text-decoration 0.3s ease;
}

/* Better visibility for small text */
.small, .form-text {
    color: #6c757d;
}

/* Enhanced disabled state for buttons */
.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Better focus states */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: none;
}

/* Smoother transitions for all interactive elements */
button, a, input, select, textarea {
    transition: all 0.2s ease;
}

/* Better styling for empty states */
.display-1 {
    font-size: 6rem;
    font-weight: 300;
    line-height: 1;
}

/* Enhanced heading styling */
.h1, .h2, .h3, .h4, .h5, .h6,
h1, h2, h3, h4, h5, h6 {
    word-spacing: 0.05em;
    letter-spacing: -0.02em;
}

/* Better list styling */
ul, ol {
    margin-bottom: 1rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Enhanced table styling */
table {
    margin-bottom: 1rem;
}

thead {
    background-color: #f8f9fa;
}

/* Better border styling */
.border {
    border-color: #dee2e6 !important;
}

.border-top {
    border-top-color: #dee2e6 !important;
}

.border-bottom {
    border-bottom-color: #dee2e6 !important;
}

/* Enhanced hr styling */
hr {
    opacity: 0.3;
    margin: 2rem 0;
}

/* Better scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Better focus visible for accessibility */
:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Enhanced input placeholder styling */
::placeholder {
    color: #adb5bd;
    opacity: 1;
}

/* Better selection styling */
::selection {
    background-color: #0d6efd;
    color: white;
}

/* Improved code and pre styling */
code {
    word-break: break-word;
}

pre {
    overflow-x: auto;
}

/* Better list marker styling */
ul > li::marker {
    color: #0d6efd;
}

ol > li::marker {
    color: #0d6efd;
    font-weight: 600;
}

/* Enhanced container max-width for better readability */
@media (min-width: 1400px) {
    .container-lg {
        max-width: 1200px;
    }
}

/* Item description - translate full text but display limited lines */
.item-description {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
}

/* Feed description styling */
.feed-description {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Feed card styling */
.feed-card {
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
}

.feed-card:hover {
    border-left-color: #0d6efd;
    transform: translateX(2px);
}

/* Optimized button spacing for feeds */
.feed-card .btn-group,
.feed-card .d-flex.gap-1 {
    flex-wrap: wrap;
}

/* Badge responsive sizing */
@media (max-width: 576px) {
    .badge {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.6rem !important;
    }
}

/* Category modal styling */
.modal-body .form-label {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.modal-body .form-select,
.modal-body .form-control {
    margin-bottom: 1rem;
}

/* Button groups styling */
.btn-group {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    border-radius: 0.375rem;
}

.btn-group .btn {
    border-radius: 0;
    transition: all 0.2s ease;
}

.btn-group .btn:first-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

.btn-group .btn:last-child {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

.btn-group .btn:hover {
    z-index: 1;
    transform: translateY(-1px);
}

/* Button group responsive */
.btn-group .btn span {
    font-weight: 500;
}

@media (max-width: 576px) {
    .btn-group {
        width: 100%;
    }
    
    .btn-group .btn {
        flex: 1;
        font-size: 0.8rem;
    }
}

/* Items list styling */
#items-container > article {
    animation: slideInUp 0.3s ease;
}

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

/* Item images */
#items-container img {
    max-width: 100%;
    height: auto;
    transition: transform 0.2s ease;
}

#items-container article:hover img {
    transform: scale(1.02);
}

/* Item badges styling */
#items-container .badge {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Item links styling */
#items-container a.text-decoration-none {
    transition: color 0.2s ease;
}

#items-container article:hover a.text-decoration-none {
    color: #0d6efd !important;
}

/* Load more button styling */
#load-more-btn {
    min-width: 200px;
    transition: all 0.3s ease;
}

#load-more-btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

/* Feed title styling */
#feed-title {
    word-break: break-word;
}

/* TTS Control Panel */
#speechControls {
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    animation: slideUp 0.3s ease;
}

#speechControls .btn {
    font-size: 0.875rem;
    padding: 0.4rem 0.6rem;
    transition: all 0.2s ease;
}

#speechControls .btn:hover {
    transform: translateY(-2px);
}

#speechControls .btn-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    border: none;
}

#speechControls .btn-primary:hover {
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
}

#speechControls .btn-outline-secondary {
    border-color: #dee2e6;
}

#speechControls .btn-outline-secondary:hover {
    background-color: #f8f9fa;
}

/* Highlighted text during TTS */
#article-body .bg-primary.text-white {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

/* History page items */
.news-item {
    border-left: 4px solid #0d6efd;
    transition: all 0.3s ease;
}

.news-item:hover {
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.15) !important;
    transform: translateY(-2px);
}

.news-item .badge {
    border-radius: 0.375rem;
    font-size: 0.75rem !important;
}

.news-item .badge.bg-primary-light {
    background-color: rgba(13, 110, 253, 0.1) !important;
}

.item-description {
    color: #6c757d;
}

/* Categories feeds list */
[id^="cat-feeds-"] .list-group {
    border-radius: 0.5rem;
}

[id^="cat-feeds-"] .list-group-item {
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    padding: 0.75rem 1rem !important;
    text-decoration: none !important;
    color: inherit !important;
}

[id^="cat-feeds-"] .list-group-item:hover {
    background-color: #f8f9fa;
    border-left-color: #0d6efd;
    transform: translateX(2px);
}

[id^="cat-feeds-"] .list-group-item .badge {
    font-size: 0.7rem !important;
    padding: 0.35rem 0.5rem;
}

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

/* Categories page styling */
.category-card {
    border-left: 4px solid #0d6efd;
    transition: all 0.3s ease;
}

.category-card:hover {
    box-shadow: 0 8px 24px rgba(13, 110, 253, 0.12) !important;
    transform: translateY(-4px);
    border-left-color: #0d6efd;
}

.category-card .cursor-pointer {
    transition: all 0.2s ease;
}

.category-card .cursor-pointer:hover {
    color: #0d6efd;
}

.category-card .badge {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%) !important;
    font-weight: 500;
    padding: 0.4rem 0.75rem !important;
    border-radius: 0.375rem;
}

.category-card .btn-group-vertical .btn {
    padding: 0.35rem 0.5rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.category-card .btn-group-vertical .btn:hover {
    transform: scale(1.1);
}

.category-card .btn-outline-danger:hover {
    color: #dc3545 !important;
    border-color: #dc3545 !important;
}

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

/* Responsive adjustments */
@media (max-width: 576px) {
    .category-card {
        border-left: 3px solid #0d6efd;
    }

    .category-card .card-body {
        padding: 1rem !important;
    }

    .category-card .badge {
        font-size: 0.7rem !important;
    }
}
