:root { 
    --primary-color: #0056a0; /* Deeper Cognex Blue */
    --secondary-color: #003a70; 
    --accent-color: #00b0f0; /* Bright Blue Accent */
    --cognex-red: #e11b22;
    --light-bg: #f2f5f8; 
    --text-dark: #212529;
    --text-light: #6c757d;
}

body { 
    font-family: 'Poppins', sans-serif; 
    background-color: var(--light-bg); 
    color: var(--text-dark);
}

/* --- Animated Header --- */
.header { 
    background: linear-gradient(-45deg, var(--secondary-color), var(--primary-color), var(--accent-color)); 
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: white; 
    padding: 4rem 0; 
    margin-bottom: 3rem; 
    position: relative;
    overflow: hidden;
    border-bottom: 5px solid var(--accent-color);
}

.cognex-animation {
    position: absolute; top: 0; right: 0; width: 150px; height: 100%;
    display: flex; align-items: center; justify-content: center; opacity: 0.5;
}
.cog-wheel {
    position: absolute; border: 3px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%; border-top-color: var(--cognex-red);
    animation: spin 4s linear infinite;
}
.cog-wheel.small { width: 40px; height: 40px; animation-delay: 0.5s; animation-direction: reverse; }
.cog-wheel.medium { width: 70px; height: 70px; animation-delay: 1s; }
.cog-wheel.large { width: 100px; height: 100px; animation-delay: 1.5s; animation-direction: reverse; }


/* --- Section & Form Styling --- */
.section-title {
    text-align: center;
    position: relative;
    color: var(--secondary-color);
    margin-bottom: 2.5rem !important;
}
.section-title span {
    background: var(--light-bg);
    padding: 0 15px;
    position: relative;
    z-index: 1;
}
.section-title::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: #ddd;
    z-index: 0;
}

.app-selector-card { 
    cursor: pointer; 
    border: 1px solid #e0e0e0; 
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    height: 100%; 
    border-radius: 15px; 
    background-color: #fff;
}
.app-selector-card:hover { 
    transform: translateY(-10px); 
    box-shadow: 0 12px 28px rgba(0, 58, 112, 0.15); 
}
.app-selector-card.active { 
    border-color: var(--primary-color); 
    box-shadow: 0 10px 30px rgba(0, 86, 160, 0.3);
    transform: translateY(-5px);
}
.app-selector-card .icon { font-size: 3rem; color: var(--primary-color); transition: color 0.3s; }
.app-selector-card:hover .icon { color: var(--accent-color); }

.form-container { 
    background: white; 
    border-radius: 15px; 
    box-shadow: 0 8px 25px rgba(0,0,0,0.08); 
    padding: 2.5rem; 
    display: none; 
    border-top: 5px solid var(--primary-color);
}
.form-title { color: var(--secondary-color); }

.form-container.active { 
    display: block; 
    animation: slideIn 0.5s ease forwards; 
}

/* --- Results & Dashboard Styling --- */
.result-card { 
    background: #fff; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.07); 
    margin-bottom: 1.5rem; overflow: hidden; transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #e9ecef;
}
.result-card:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0,0,0,0.1); }
.result-card-img { background-color: #f8f9fa; padding: 1rem; display: flex; align-items: center; justify-content: center; height: 200px; }
.result-card-img img { max-height: 180px; width: auto; max-width: 100%; object-fit: contain; }

.btn-primary { 
    background-color: var(--primary-color); border-color: var(--primary-color); 
    transition: background-color 0.2s;
}
.btn-primary:hover { background-color: var(--secondary-color); border-color: var(--secondary-color); }

.dashboard-title { color: var(--secondary-color); }
.table-hover tbody tr:hover {
    background-color: #e9f5ff;
    cursor: pointer;
}

/* --- Database Connection Loader --- */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.75s ease-out, visibility 0.75s ease-out;
    opacity: 1;
    visibility: visible;
}

.loader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
    color: var(--secondary-color);
}

.db-icon-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 3rem;
    color: var(--primary-color);
}

.db-icon-container .bi-hdd-stack-fill {
    animation: pulse 2s infinite ease-in-out;
}

.db-icon-container .bi-server {
    animation: pulse 2s infinite ease-in-out 0.5s; /* Delayed start */
}

.dots span {
    opacity: 0;
    animation: ellipsis 1.5s infinite;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

.dots span:nth-child(1) {
    animation-delay: 0.1s;
}
.dots span:nth-child(2) {
    animation-delay: 0.3s;
}
.dots span:nth-child(3) {
    animation-delay: 0.5s;
}

/* --- DB Status Indicator --- */
#db-status-indicator {
    padding: 0.5em 1em;
    font-weight: 500;
    transition: background-color 0.3s ease, color 0.3s ease;
    background-color: #6c757d; /* Default gray */
    color: white;
}

.status-connected {
    background-color: #198754; /* Bootstrap success green */
    animation: pulse-green 2s infinite;
}

.status-disconnected {
    background-color: #dc3545; /* Bootstrap danger red */
}


/* --- ALL KEYFRAME ANIMATIONS --- */

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes slideIn { 
    from { opacity: 0; transform: translateY(20px); } 
    to { opacity: 1; transform: translateY(0); } 
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

@keyframes ellipsis {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(25, 135, 84, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(25, 135, 84, 0);
    }
}


:root { 
    --primary-color: #0056a0; /* Deeper Cognex Blue */
    --secondary-color: #003a70; 
    --accent-color: #00b0f0; /* Bright Blue Accent */
    --cognex-red: #e11b22;
    --light-bg: #f2f5f8; 
    --text-dark: #212529;
    --text-light: #6c757d;
}

body { 
    font-family: 'Poppins', sans-serif; 
    background-color: var(--light-bg); 
    color: var(--text-dark);
}

/* --- Animated Header --- */
.header { 
    background: linear-gradient(-45deg, var(--secondary-color), var(--primary-color), var(--accent-color)); 
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: white; 
    padding: 4rem 0; 
    margin-bottom: 3rem; 
    position: relative;
    overflow: hidden;
    border-bottom: 5px solid var(--accent-color);
}

.cognex-animation {
    position: absolute; top: 0; right: 0; width: 150px; height: 100%;
    display: flex; align-items: center; justify-content: center; opacity: 0.5;
}
.cog-wheel {
    position: absolute; border: 3px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%; border-top-color: var(--cognex-red);
    animation: spin 4s linear infinite;
}
.cog-wheel.small { width: 40px; height: 40px; animation-delay: 0.5s; animation-direction: reverse; }
.cog-wheel.medium { width: 70px; height: 70px; animation-delay: 1s; }
.cog-wheel.large { width: 100px; height: 100px; animation-delay: 1.5s; animation-direction: reverse; }


/* --- Section & Form Styling --- */
.section-title {
    text-align: center;
    position: relative;
    color: var(--secondary-color);
    margin-bottom: 2.5rem !important;
}
.section-title span {
    background: var(--light-bg);
    padding: 0 15px;
    position: relative;
    z-index: 1;
}
.section-title::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: #ddd;
    z-index: 0;
}

.app-selector-card { 
    cursor: pointer; 
    border: 1px solid #e0e0e0; 
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    height: 100%; 
    border-radius: 15px; 
    background-color: #fff;
}
.app-selector-card:hover { 
    transform: translateY(-10px); 
    box-shadow: 0 12px 28px rgba(0, 58, 112, 0.15); 
}
.app-selector-card.active { 
    border-color: var(--primary-color); 
    box-shadow: 0 10px 30px rgba(0, 86, 160, 0.3);
    transform: translateY(-5px);
}
.app-selector-card .icon { font-size: 3rem; color: var(--primary-color); transition: color 0.3s; }
.app-selector-card:hover .icon { color: var(--accent-color); }

.form-container { 
    background: white; 
    border-radius: 15px; 
    box-shadow: 0 8px 25px rgba(0,0,0,0.08); 
    padding: 2.5rem; 
    display: none; 
    border-top: 5px solid var(--primary-color);
}
.form-title { color: var(--secondary-color); }

.form-container.active { 
    display: block; 
    animation: slideIn 0.5s ease forwards; 
}

/* --- Results & Dashboard Styling --- */
.result-card { 
    background: #fff; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.07); 
    margin-bottom: 1.5rem; overflow: hidden; transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #e9ecef;
}
.result-card:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0,0,0,0.1); }
.result-card-img { background-color: #f8f9fa; padding: 1rem; display: flex; align-items: center; justify-content: center; height: 200px; }
.result-card-img img { max-height: 180px; width: auto; max-width: 100%; object-fit: contain; }

.btn-primary { 
    background-color: var(--primary-color); border-color: var(--primary-color); 
    transition: background-color 0.2s;
}
.btn-primary:hover { background-color: var(--secondary-color); border-color: var(--secondary-color); }

.dashboard-title { color: var(--secondary-color); }
.table-hover tbody tr:hover {
    background-color: #e9f5ff;
    cursor: pointer;
}

/* --- Database Connection Loader --- */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.75s ease-out, visibility 0.75s ease-out;
    opacity: 1;
    visibility: visible;
}

.loader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
    color: var(--secondary-color);
}

.db-icon-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 3rem;
    color: var(--primary-color);
}

.db-icon-container .bi-hdd-stack-fill {
    animation: pulse 2s infinite ease-in-out;
}

.db-icon-container .bi-server {
    animation: pulse 2s infinite ease-in-out 0.5s; /* Delayed start */
}

.dots span {
    opacity: 0;
    animation: ellipsis 1.5s infinite;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

.dots span:nth-child(1) { animation-delay: 0.1s; }
.dots span:nth-child(2) { animation-delay: 0.3s; }
.dots span:nth-child(3) { animation-delay: 0.5s; }

/* --- DB Status Indicator --- */
#db-status-indicator {
    padding: 0.5em 1em;
    font-weight: 500;
    transition: background-color 0.3s ease, color 0.3s ease;
    background-color: #6c757d; /* Default gray */
    color: white;
}

.status-connected {
    background-color: #198754; /* Bootstrap success green */
    animation: pulse-green 2s infinite;
}

.status-disconnected {
    background-color: #dc3545; /* Bootstrap danger red */
}


/* --- NEW: Transparent Admin Page Styles --- */
.admin-page .form-container,
.admin-page #dashboard-section .card {
    background-color: transparent;
    border: none;
    box-shadow: none;
    padding: 0; /* Remove padding from the card container */
}

/* Make login form text more visible on the light background */
.admin-page .form-container .form-label {
    color: var(--text-dark);
    font-weight: 500;
}

/* Add a subtle background to the table to make it pop */
.admin-page .table {
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
}

/* Make the striped rows a bit more visible on the transparent background */
.admin-page .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: rgba(0, 0, 0, 0.03);
}


/* --- ALL KEYFRAME ANIMATIONS --- */
@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes slideIn { 
    from { opacity: 0; transform: translateY(20px); } 
    to { opacity: 1; transform: translateY(0); } 
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
@keyframes ellipsis {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}
@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(25, 135, 84, 0); }
    100% { box-shadow: 0 0 0 0 rgba(25, 135, 84, 0); }
}