/* Mobile-Specific Enhancements */

/* Smooth scrolling for the entire page */
html {
    scroll-behavior: smooth;
}

/* Improved touch interactions */
* {
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    -webkit-touch-callout: none;
}

/* Better focus states for mobile */
.btn:focus,
.form-control:focus,
.nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Improved button spacing on mobile */
@media (max-width: 767px) {
    .btn-group {
        gap: 0.5rem;
    }
    
    .btn-group .btn {
        flex: 1;
        min-width: 120px;
    }
    
    /* Stack buttons vertically on very small screens */
    .d-flex.gap-3 .btn {
        width: 100%;
    }
}

/* Better modal handling on mobile */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }
    
    .modal-content {
        border-radius: 16px;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
    }
}

/* Improved form inputs on mobile */
@media (max-width: 767px) {
    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.875rem 1rem;
    }
    
    .form-label {
        font-size: 0.95rem;
        font-weight: 600;
    }
}

/* Better card layouts on mobile */
@media (max-width: 767px) {
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 1rem;
    }
    
    .card-header h4 {
        font-size: 1.1rem;
        margin-bottom: 0;
    }
}

/* Improved hero section on mobile */
@media (max-width: 767px) {
    .display-4 {
        font-size: 1.8rem;
        line-height: 1.2;
    }
    
    .lead {
        font-size: 1rem;
        line-height: 1.5;
    }
    
    .container .my-4 {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
    }
}

/* Better navbar on mobile */
@media (max-width: 991px) {
    .navbar-collapse {
        margin-top: 1rem;
        background: rgba(255, 255, 255, 0.15);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-radius: 12px;
        padding: 1rem;
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .navbar-nav {
        gap: 0.5rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 8px;
        text-align: center;
    }
    
    .navbar-text {
        margin-bottom: 0.5rem;
        text-align: center;
    }
}

/* Improved project cards on mobile */
@media (max-width: 767px) {
    .project-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .project-card h5 {
        font-size: 1.1rem;
    }
    
    .project-card .btn-group-sm {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }
    
    .project-card .btn-sm {
        width: 100%;
        padding: 0.75rem 1rem;
        margin-bottom: 0;
        font-weight: 600;
        min-height: 44px;
    }
}

/* Better button group spacing for all screen sizes */
.btn-group-sm {
    gap: 0.5rem;
}

.btn-group-sm .btn-sm {
    min-width: 90px;
    white-space: nowrap;
}

/* Enhanced button contrast for project cards */
.project-card .btn-outline-primary {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.project-card .btn-outline-success {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.5);
    color: white;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.project-card .btn-outline-danger {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: white;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Button icons and text spacing */
.btn i {
    margin-right: 0.5rem;
}

.btn i:last-child {
    margin-right: 0;
    margin-left: 0.5rem;
}

/* Spinner in buttons */
.btn .spinner-border-sm {
    width: 0.875rem;
    height: 0.875rem;
    margin-right: 0.5rem;
}

/* Better contrast for status badges */
.status-badge {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white !important;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.status-completed {
    background: rgba(16, 185, 129, 0.3) !important;
    border-color: rgba(16, 185, 129, 0.5);
    color: white !important;
}

.status-crawling {
    background: rgba(13, 202, 240, 0.3) !important;
    border-color: rgba(13, 202, 240, 0.5);
    color: white !important;
}

.status-error {
    background: rgba(239, 68, 68, 0.3) !important;
    border-color: rgba(239, 68, 68, 0.5);
    color: white !important;
}

.status-pending {
    background: rgba(108, 117, 125, 0.3) !important;
    border-color: rgba(108, 117, 125, 0.5);
    color: white !important;
}

/* Better stats grid on mobile */
@media (max-width: 767px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.5rem 1rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
}

/* Improved url list on mobile */
@media (max-width: 767px) {
    .url-list {
        max-height: 300px;
    }
    
    .url-item {
        padding: 0.75rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .url-status {
        margin-right: 0.5rem;
        margin-bottom: 0.25rem;
    }
    
    .url-info {
        width: 100%;
    }
    
    .url-title {
        font-size: 0.9rem;
    }
    
    .url-link {
        font-size: 0.8rem;
        word-break: break-all;
    }
}

/* Better breadcrumbs on mobile */
@media (max-width: 576px) {
    .breadcrumb {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
}

/* Improved polling indicator on mobile - positioned to not overlap with toasts */
@media (max-width: 767px) {
    .polling-indicator {
        top: 80px;
        right: 10px;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        z-index: 1070; /* Below toasts but above modals */
    }
}

/* Adjust polling indicator position when it might overlap with toasts */
@media (max-width: 576px) {
    .polling-indicator {
        top: 70px;
        right: 0.5rem;
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        z-index: 1070;
    }
    
    /* When both toast and polling indicator are present, adjust positions */
    .toast-container:not(:empty) ~ .polling-indicator,
    .polling-indicator.active + .toast-container {
        top: 120px; /* Move further down when both are active */
    }
}

/* Better toast notifications on mobile - Always above modals */
@media (max-width: 767px) {
    .toast-container {
        top: 80px; /* Below navbar on mobile */
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        width: calc(100% - 2rem);
        max-width: 400px;
        z-index: 1080 !important; /* Always above modals */
    }
    
    .toast {
        min-width: auto;
        width: 100%;
        margin-bottom: 0.5rem;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), var(--glass-shadow);
    }
}

/* Enhanced mobile toast positioning for small screens */
@media (max-width: 576px) {
    .toast-container {
        top: 70px;
        left: 1rem;
        right: 1rem;
        transform: none;
        width: auto;
        max-width: none;
        z-index: 1080 !important;
    }
    
    .toast {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }
}

/* Improved loading states */
.loading-overlay {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Better focus management for accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Improved selection colors */
::selection {
    background-color: rgba(102, 126, 234, 0.3);
    color: inherit;
}

::-moz-selection {
    background-color: rgba(102, 126, 234, 0.3);
    color: inherit;
}

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

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

/* Improved animation performance */
@media (prefers-reduced-motion: no-preference) {
    .glass:hover {
        transform: translateY(-2px);
        transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .btn:hover {
        transform: translateY(-1px);
        transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* Dark mode improvements */
@media (prefers-color-scheme: dark) {
    .card {
        background: rgba(30, 41, 59, 0.4);
        border-color: rgba(255, 255, 255, 0.1);
        color: white;
    }
    
    .form-control {
        background: rgba(30, 41, 59, 0.3);
        border-color: rgba(255, 255, 255, 0.2);
        color: white;
    }
    
    .form-control:focus {
        background: rgba(30, 41, 59, 0.4);
        border-color: var(--primary-color);
        color: white;
    }
}

/* High contrast mode improvements */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
        font-weight: 700;
    }
    
    .form-control {
        border: 2px solid currentColor;
    }
    
    .card {
        border: 2px solid currentColor;
    }
}

/* Print styles */
@media print {
    .navbar,
    .btn,
    .modal,
    .toast-container,
    .polling-indicator {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .card {
        background: white !important;
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
}

/* Better form validation styles */
.form-control.is-invalid {
    border-color: var(--danger-color);
    background-color: rgba(239, 68, 68, 0.1);
    color: white;
}

.form-control.is-valid {
    border-color: var(--success-color);
    background-color: rgba(16, 185, 129, 0.1);
    color: white;
}

/* Improved loading states for better UX */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading .spinner-border {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
}

/* Better image handling */
img {
    max-width: 100%;
    height: auto;
}

/* Improved table responsiveness */
@media (max-width: 767px) {
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
}

/* Better progress bars */
.progress {
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    transition: width 0.3s ease;
}

/* Enhanced error states */
.alert {
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.alert-dismissible .btn-close {
    padding: 0.5rem;
    margin: -0.5rem -0.5rem -0.5rem auto;
}

/* Better modal backdrop */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* Improved accessibility for screen readers */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Better skip links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

 