/* ============================================
   FILE: css/style.css
   ============================================ */

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
}

/* Native <select> lists are drawn by the OS; dark colour-scheme + light popup = white-on-white text.
   Force light form controls for the whole document (fixes Chrome/Edge on Windows). */
html {
    color-scheme: light;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Navigation Styles */
.navbar {
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.navbar-brand {
    color: #fff !important;
    font-weight: bold;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
}

.navbar-logo {
    height: 40px;
    width: auto;
    margin-right: 10px;
    filter: brightness(1.2);
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    transition: all 0.3s ease;
    margin: 0 0.5rem;
}

.navbar-nav .nav-link:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.btn-login {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #fff;
    color: #fff !important;
    border-radius: 25px;
    padding: 0.5rem 1.5rem;
    transition: all 0.3s ease;
}

.btn-login:hover {
    background: #fff;
    color: #667eea !important;
    transform: translateY(-2px);
}

/* Hero Section */
.hero-section {
    padding: 5rem 0 3rem;
    color: #fff;
    text-align: center;
}

.hero-section h1 {
    font-size: 3.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    animation: fadeInUp 0.8s ease;
}

.hero-section p {
    font-size: 1.3rem;
    opacity: 0.9;
    animation: fadeInUp 1s ease;
}

/* Stats Cards */
.stats-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 1.5rem;
    text-align: center;
    color: #fff;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
}

.stats-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.2);
}

.stats-card .stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stats-card .stat-label {
    font-size: 1rem;
    opacity: 0.9;
}

/* Section toolbars (Belt Scraper, Roller Monitor) */
.section-toolbar.card {
    background: linear-gradient(135deg, #3d3a4a 0%, #2d2a36 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    color-scheme: light;
    /* Bootstrap 5.3+: light theme for any BS controls inside dark toolbar */
    --bs-body-color: #212529;
    --bs-body-bg: #fff;
}

.section-toolbar .card-body {
    padding: 1rem 1.25rem;
}

.section-toolbar .form-label {
    color: rgba(255, 255, 255, 0.9);
}

/* Light fields on dark toolbar: avoids white-on-white when the OS paints the
   closed <select> with a light background, and fixes option list contrast. */
/* Force light UI for native selects (stops dark color-scheme + white text in option list) */
.section-toolbar .form-select,
.section-toolbar .form-control {
    background: #fff !important;
    border-color: rgba(0, 0, 0, 0.15);
    color: #212529 !important;
    color-scheme: light;
}

.section-toolbar .form-select:focus,
.section-toolbar .form-control:focus {
    background: #fff !important;
    border-color: rgba(13, 110, 253, 0.55);
    color: #212529 !important;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.2);
    color-scheme: light;
}

.section-toolbar .form-select option,
.section-toolbar .form-select optgroup {
    background-color: #fff !important;
    color: #000 !important;
}

/* Non-highlighted options (WebKit/Blink sometimes respect these) */
.section-toolbar .form-select option:not(:checked) {
    background-color: #fff !important;
    color: #212529 !important;
}

.section-toolbar .btn-primary {
    background: rgba(102, 126, 234, 0.9);
    border-color: rgba(102, 126, 234, 0.9);
}

.section-toolbar .btn-primary:hover {
    background: rgba(102, 126, 234, 1);
    border-color: rgba(102, 126, 234, 1);
}

/* Chart Cards */
.chart-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.chart-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.chart-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.status-badge {
    padding: 0.3rem 1rem;
    background: rgba(46, 213, 115, 0.2);
    border: 1px solid #2ed573;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #2ed573;
}

.status-badge.offline {
    background: rgba(255, 71, 87, 0.2);
    border-color: #ff4757;
    color: #ff4757;
}

.chart-container {
    min-height: 300px;
}

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

/* Loading Spinner */
.chart-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .hero-section p {
        font-size: 1rem;
    }
    
    .stats-card .stat-value {
        font-size: 2rem;
    }
    
    .chart-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 576px) {
    .hero-section {
        padding: 4rem 0 2rem;
    }
    
    .navbar-brand {
        font-size: 1.2rem;
    }
}

/* Dropdown Menu Styles */
.dropdown-menu {
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    margin-top: 0.5rem;
    background-color: #fff;
    --bs-dropdown-bg: #fff;
    --bs-dropdown-color: #212529;
    --bs-dropdown-link-color: #212529;
    --bs-dropdown-link-hover-color: #667eea;
    --bs-dropdown-link-hover-bg: rgba(102, 126, 234, 0.12);
    --bs-dropdown-link-active-color: #fff;
    --bs-dropdown-link-active-bg: #667eea;
}

/* Navbar dropdown: do not inherit .navbar-dark white link colour (white-on-white menu text) */
.navbar .dropdown-menu {
    color: #212529;
}

.navbar .dropdown-menu .dropdown-item {
    color: #212529 !important;
    background-color: transparent;
}

.navbar .dropdown-menu .dropdown-item:hover,
.navbar .dropdown-menu .dropdown-item:focus {
    background: rgba(102, 126, 234, 0.12) !important;
    color: #667eea !important;
}

.dropdown-item {
    padding: 0.75rem 1.25rem;
    transition: all 0.3s ease;
    color: #212529;
}

.dropdown-item:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.dropdown-item i {
    margin-right: 0.5rem;
    width: 20px;
    text-align: center;
}

/* Modal Styles */
.modal-content {
    border-radius: 20px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    background: var(--primary-gradient);
    color: #fff;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-bottom: none;
    padding: 1.5rem;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

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

.modal-body {
    padding: 2rem;
}

.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    transform: none;
}

/* Admin Panel Styles */
.table {
    color: #333;
}

.table thead {
    background: rgba(102, 126, 234, 0.1);
}

.table thead th {
    border-bottom: 2px solid #667eea;
    font-weight: 600;
    padding: 1rem;
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

.table tbody td {
    vertical-align: middle;
    padding: 0.75rem;
}

.table code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.badge {
    padding: 0.4rem 0.8rem;
    font-weight: 500;
}

.btn-sm {
    margin: 0 0.2rem;
}

.form-check-input:checked {
    background-color: #667eea;
    border-color: #667eea;
}

.form-switch .form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}

.form-switch .form-check-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.alert {
    border-radius: 10px;
    border: none;
    padding: 1rem;
}

.alert-success {
    background: rgba(46, 213, 115, 0.2);
    color: #1e7e34;
}

.alert-danger {
    background: rgba(255, 71, 87, 0.2);
    color: #c82333;
}

.btn-danger {
    background: linear-gradient(135deg, #ff4757 0%, #dc3545 100%);
    border: none;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 71, 87, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    border: none;
}

/* Print Styles */
@media print {
    .navbar,
    .btn-login {
        display: none;
    }

    body {
        background: #fff;
    }

    .chart-card {
        page-break-inside: avoid;
    }
}