/* Custom CSS for HELI-Cas */

/* Page Load Spinner Overlay */
#page-loader {
    position: fixed;
    inset: 0;
    background: rgba(19, 42, 19, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease;
}
#page-loader.hidden {
    opacity: 0;
    pointer-events: none;
}
.loader {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: animloader 1s linear infinite;
}
@keyframes animloader {
    0%   { box-shadow: -72px 0 #FFF inset; }
    100% { box-shadow:  48px 0 #FFF inset; }
}
:root {
    --primary-color: #4f772d;
    --secondary-color: #31572c;
    --success-color: #90a955;
    --info-color: #ecf39e;
    --warning-color: #90a955;
    --danger-color: #31572c;
    --dark-color: #132a13;
    --light-color: #ecf39e;
    --bs-primary: #4f772d;
    --bs-primary-rgb: 79, 119, 45;
    --bs-secondary: #31572c;
    --bs-secondary-rgb: 49, 87, 44;
    --bs-success: #90a955;
    --bs-success-rgb: 144, 169, 85;
    --bs-info: #ecf39e;
    --bs-info-rgb: 236, 243, 158;
    --bs-warning: #90a955;
    --bs-warning-rgb: 144, 169, 85;
    --bs-danger: #31572c;
    --bs-danger-rgb: 49, 87, 44;
    --bs-light: #ecf39e;
    --bs-light-rgb: 236, 243, 158;
    --bs-dark: #132a13;
    --bs-dark-rgb: 19, 42, 19;
}

/* Bootstrap Color Overrides */
.bg-primary {
    background-color: var(--primary-color) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

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

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: #31572c !important;
    border-color: #31572c !important;
    color: white !important;
}

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

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    background-color: var(--info-color) !important;
    border-color: var(--primary-color) !important;
    color: var(--dark-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

.navbar-dark .navbar-brand,
.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
}

.navbar-dark .navbar-nav .nav-link:hover,
.navbar-dark .navbar-nav .nav-link:focus {
    color: #fff !important;
}

.bg-success {
    background-color: var(--success-color) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.bg-info {
    background-color: var(--info-color) !important;
}

.text-info {
    color: var(--info-color) !important;
}

.bg-warning {
    background-color: var(--warning-color) !important;
}

.text-warning {
    color: var(--warning-color) !important;
}

.bg-secondary {
    background-color: var(--secondary-color) !important;
}

.text-secondary {
    color: var(--secondary-color) !important;
}

.badge.bg-primary {
    background-color: var(--primary-color) !important;
}

.badge.bg-success {
    background-color: var(--success-color) !important;
}

.badge.bg-info {
    background-color: var(--info-color) !important;
    color: var(--dark-color) !important;
}

.badge.bg-warning {
    background-color: var(--warning-color) !important;
    color: var(--dark-color) !important;
}

.badge.bg-secondary {
    background-color: var(--secondary-color) !important;
}

.spinner-border.text-primary {
    color: var(--primary-color) !important;
}

.card-header.bg-primary {
    background-color: var(--primary-color) !important;
    color: white !important;
}

/* Global Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    padding-top: 76px;
}

.section-padding {
    padding: 80px 0;
}

.section-header h2 {
    position: relative;
    margin-bottom: 1rem;
}

.section-header h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* Navigation Styles */
.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    margin: 0 0.5rem;
    transition: all 0.3s ease;
    position: relative;
    padding: 0.5rem 1rem !important;
}

.navbar-nav .nav-link:hover {
    color: var(--info-color) !important;
}

.navbar-nav .nav-link:hover::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 2px;
    background-color: var(--info-color);
    border-radius: 1px;
    animation: slideIn 0.3s ease;
}

.navbar-nav .nav-link.active {
    color: var(--info-color) !important;
    border-radius: 0.375rem;
}

.navbar-nav .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 2px;
    border-radius: 1px;
}

@keyframes slideIn {
    from {
        width: 0%;
    }
    to {
        width: 80%;
    }
}

/* Hero Section */
.hero-section {
    background: #f5f5f5;
    color: #333;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><pattern id="grain" patternUnits="userSpaceOnUse" width="100" height="100"><circle cx="50" cy="50" r="1" fill="%23ffffff" opacity="0.1"/></pattern></defs><rect width="100%" height="100%" fill="url(%23grain)"/></svg>');
}

.hero-content {
    position: relative;
    z-index: 2;
}

.feature-highlights .feature-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.hero-visual {
    position: relative;
    z-index: 2;
}

.analysis-preview .card {
    transform: rotate(-2deg);
    transition: transform 0.3s ease;
}

.analysis-preview .card:hover {
    transform: rotate(0deg) scale(1.02);
}

.sequence-display {
    background: #ecf39e;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    border: 1px solid #90a955;
}

.stat-item .stat-number {
    font-size: 1.5rem;
    font-weight: bold;
}

.stat-item .stat-label {
    font-size: 0.8rem;
    color: #31572c;
}

/* Form Styles */
.card {
    border: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1) !important;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(79, 119, 45, 0.25);
}

.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-check:checked + .btn {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Analysis Options */
.analysis-options {
    background: #ecf39e;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid #90a955;
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Results Section */
.table-hover tbody tr:hover {
    background-color: rgba(79, 119, 45, 0.1);
}

.badge {
    font-size: 0.9rem;
    padding: 0.5em 0.8em;
}

#processingIndicator .spinner-border {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Progress Animation */
.progress-bar-animated {
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% { background-position: 1rem 0; }
    100% { background-position: 0 0; }
}

/* Documentation */
.list-group-item {
    border: none;
    border-radius: 0.5rem !important;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.list-group-item:hover {
    background-color: #ecf39e;
}

.list-group-item.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.tab-content .card {
    border-radius: 1rem;
}

.citation-box {
    border-left: 4px solid var(--primary-color);
}

/* Contact Section */
.contact-item {
    transition: transform 0.3s ease;
}

.contact-item:hover {
    transform: translateY(-10px);
}

.contact-icon {
    transition: transform 0.3s ease;
}

.contact-item:hover .contact-icon {
    transform: scale(1.2);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    .hero-section {
        padding: 60px 0;
    }
    
    .hero-content h1 {
        font-size: 2.5rem;
    }
    
    .section-padding {
        padding: 60px 0;
    }
    
    .hero-buttons .btn {
        margin-bottom: 1rem;
        width: 100%;
    }
    
    .analysis-preview .card {
        transform: none;
        margin-top: 2rem;
    }
}

@media (max-width: 576px) {
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .display-5 {
        font-size: 2rem;
    }
    
    .section-padding {
        padding: 40px 0;
    }
    
    .card-body {
        padding: 1.5rem;
    }
}

/* Loading Animation */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Scroll Animation */
.scroll-animate {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.6s ease;
}

.scroll-animate.active {
    opacity: 1;
    transform: translateY(0);
}

/* Chart Container */
#summaryChart {
    max-height: 200px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: #31572c;
}

/* Print Styles */
@media print {
    .navbar,
    .hero-section,
    #contact,
    footer {
        display: none;
    }
    
    body {
        padding-top: 0;
    }
    
    .section-padding {
        padding: 20px 0;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .hero-section {
        background: #000;
        color: #fff;
    }
    
    .card {
        border: 2px solid #000;
    }
    
    .btn-primary {
        background-color: #132a13;
        border-color: #132a13;
    }
}

/* Reduced Motion */
@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;
    }
}

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

/* Success/Error States */
.form-control.is-valid {
    border-color: var(--success-color);
}

.form-control.is-invalid {
    border-color: var(--danger-color);
}

.valid-feedback {
    color: var(--success-color);
}

.invalid-feedback {
    color: var(--danger-color);
}

/* ============================================================ */
/* === Mobile Responsiveness                                  === */
/* ============================================================ */

/* Global: prevent stray horizontal scroll on phones */
html, body {
    overflow-x: hidden;
}

/* Main HELI-Cas brand (moved out of inline style in header.php) */
.navbar-brand.cas-brand {
    font-family: 'Mitr', sans-serif;
    font-weight: 500;
    font-size: 2rem;
    letter-spacing: 1.5px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Batch-analysis sidebar: full-height only on md+; drops to natural height on phone */
@media (min-width: 768px) {
    .batch-sidebar {
        min-height: calc(100vh - 76px);
    }
}

/* ---- Tablet / medium (≤992px) ---- */
@media (max-width: 992px) {
    .navbar-brand.cas-brand {
        font-size: 1.5rem;
        letter-spacing: 1px;
    }
    /* ICAR logo in navbar: override the inline height/width */
    .navbar > a.navbar-brand img {
        height: 52px !important;
        width: 42px !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }
    .navbar {
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }
}

/* ---- Phone (≤576px) ---- */
@media (max-width: 576px) {
    body {
        padding-top: 64px;
    }

    .navbar-brand.cas-brand {
        font-size: 1.25rem;
        letter-spacing: 0.5px;
    }
    .navbar > a.navbar-brand img {
        height: 42px !important;
        width: 34px !important;
    }

    /* Tighter card padding so forms fit */
    .card-body.p-4 { padding: 1rem !important; }
    .card-body.p-5 { padding: 1.25rem !important; }

    /* Input-method toggle: slightly smaller labels so "Text Input" / "File Upload"
       both fit at 320–360px widths. */
    .btn-group.w-100 .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.4rem;
    }

    /* Ensure every primary button is a comfortable tap target on phones */
    .btn,
    .btn-sm {
        min-height: 44px;
    }

    /* Hero / section headings — tighten further than the existing 576px block */
    .hero-content h1,
    .display-4,
    .display-5 {
        font-size: 1.85rem !important;
        line-height: 1.2;
    }

    .section-padding {
        padding: 32px 0;
    }

    /* Footer: center everything, normalize image sizing */
    .footer .container { padding-left: 1rem; padding-right: 1rem; }
    .footer .copyright .row > [class^="col-"] {
        text-align: center !important;
    }
    .footer #clstr_globe + * ,
    .footer [id="clstr_globe"] {
        margin: 0 auto;
    }

    /* Results/export buttons — full width for easier tapping */
    #resultsContainer .d-grid .btn { min-height: 44px; }

    /* Table inside .table-responsive: smooth momentum scroll on iOS */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    /* FASTA input textarea: readable monospace size on small screens */
    textarea.font-monospace { font-size: 0.85rem; }

    /* Tighten processing-indicator card horizontal padding */
    #processingIndicator .card-body.p-5 { padding: 1.5rem 1rem !important; }
}

/* ---- Ultra-narrow (≤400px) ---- */
@media (max-width: 400px) {
    .navbar-brand.cas-brand {
        font-size: 1.1rem;
        letter-spacing: 0;
    }
    .navbar > a.navbar-brand img {
        height: 36px !important;
        width: 29px !important;
    }
    .btn-group.w-100 .btn {
        font-size: 0.8rem;
        padding: 0.45rem 0.3rem;
    }
    .hero-content h1,
    .display-4,
    .display-5 {
        font-size: 1.6rem !important;
    }
}