/* assets/css/styles.css - Oil Tank Monitor with Chart.js */

:root {
    --primary-color: #007bff;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --border-radius: 8px;
}

body {
    background-color: var(--light-bg);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.chart-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: transform 0.2s ease-in-out;
    overflow: hidden;
}

.chart-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.card-title {
    color: #333;
    font-weight: 600;
}

/* Chart.js Gauge Styling */
.gauge-container {
    position: relative;
    height: 300px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gauge_chart {
    max-width: 300px;
    max-height: 300px;
}

.gauge-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 10;
}

.gauge-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #333;
    line-height: 1;
}

.gauge-label {
    font-size: 1rem;
    color: #666;
    margin: 0;
}

.gauge-percentage {
    font-size: 1.2rem;
    font-weight: 600;
    color: #007bff;
    margin-top: 2px;
}

/* Chart containers */
#status_chart {
    height: 400px;
    width: 100%;
}

/* Auto-refresh section styling */
.auto-refresh-section {
    margin-top: 20px;
    padding: 10px;
    background: rgba(248, 249, 250, 0.9);
    border-radius: 5px;
}

/* Status badges */
.badge {
    font-size: 1rem;
    padding: 0.5rem 1rem;
}

/* Auto-refresh indicator */
#refresh-icon {
    animation: spin 2s linear infinite;
    animation-play-state: paused;
}

#refresh-icon.spinning {
    animation-play-state: running;
}

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

/* Alert styles */
.alert {
    border-radius: var(--border-radius);
    border: none;
}

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

/* Tank Levels Page Styles */
.btn-group-custom {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.btn-group-custom .btn {
    margin: 2px;
    min-width: 120px;
    transition: all 0.3s ease;
}

.btn-group-custom .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

#chart, #chart2 {
    width: 100%;
    height: 500px;
    margin: 0 auto;
}

/* Chart.js canvas styling */
.chart-canvas {
    max-height: 500px;
    width: 100% !important;
}

#average_daily {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
    font-weight: bold;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#average_daily .row {
    align-items: center;
}

#average_daily i {
    color: var(--primary-color);
    margin-right: 8px;
}

/* Calendar View Specific Styles */
.calendar-view #chart {
    height: auto;
    min-height: 600px;
    overflow-x: auto;
    overflow-y: visible;
    width: 100%;
}

.calendar-view #chart2 {
    display: none;
}

.calendar-view .chart-container {
    overflow: visible;
    padding: 10px;
}

/* Responsive design */
@media (max-width: 768px) {
    .container-fluid {
        padding: 5px 10px;
    }
    
    /* Fix header spacing */
    h1 {
        font-size: 1.6rem;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.3rem;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.1rem;
        line-height: 1.3;
    }
    
    /* Gauge responsive styling */
    .gauge-container {
        height: 280px;
    }
    
    #gauge_chart {
        max-width: 250px;
        max-height: 250px;
    }
    
    .gauge-value {
        font-size: 2rem;
    }
    
    .gauge-label {
        font-size: 0.9rem;
    }
    
    .gauge-percentage {
        font-size: 1rem;
    }
    
    /* Chart responsive styling */
    #status_chart {
        height: 300px;
    }
    
    .chart-canvas {
        max-height: 300px;
    }
    
    /* Fix card spacing */
    .card {
        margin-bottom: 15px;
    }
    
    .card-body {
        padding: 1rem 0.75rem;
    }
    
    .card-title {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }
    
    /* Fix badge sizing */
    .badge {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
        line-height: 1.2;
        word-wrap: break-word;
    }
    
    /* Fix auto-refresh section */
    .auto-refresh-section {
        margin-top: 15px;
        padding: 8px;
        font-size: 0.8rem;
        line-height: 1.4;
    }
    
    .auto-refresh-section small {
        display: block;
        word-wrap: break-word;
    }
    
    /* Fix row spacing */
    .row {
        margin-bottom: 10px;
    }
    
    /* Fix text wrapping */
    .text-muted {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Tank Levels Mobile Styles */
    .btn-group-custom {
        gap: 5px;
    }
    
    .btn-group-custom .btn {
        flex: 1;
        min-width: 100px;
        font-size: 0.9rem;
        padding: 0.6rem 0.75rem;
    }
    
    #chart, #chart2 {
        height: 350px;
    }
    
    /* Calendar view mobile adjustments */
    .calendar-view #chart {
        height: auto;
        min-height: 400px;
        overflow-x: scroll;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Calendar statistics mobile layout */
    .calendar-view #average_daily .col-md-3 {
        flex: 0 0 50%; /* Two columns on tablet */
        max-width: 50%;
        margin-bottom: 8px;
    }
    
    #average_daily {
        padding: 15px;
        margin: 15px 0;
    }
    
    #average_daily .col-md-4,
    #average_daily .col-md-6 {
        margin-bottom: 10px;
    }
}

@media (max-width: 576px) {
    /* Extra small mobile fixes */
    .container-fluid {
        padding: 5px;
    }
    
    h1 {
        font-size: 1.4rem;
        margin-bottom: 0.8rem;
    }
    
    h2 {
        font-size: 1.2rem;
        line-height: 1.2;
        margin-bottom: 0.5rem;
    }
    
    h3 {
        font-size: 1rem;
        line-height: 1.2;
    }
    
    /* Smaller gauge for very small screens */
    .gauge-container {
        height: 250px;
    }
    
    #gauge_chart {
        max-width: 200px;
        max-height: 200px;
    }
    
    .gauge-value {
        font-size: 1.8rem;
    }
    
    .gauge-label {
        font-size: 0.8rem;
    }
    
    .gauge-percentage {
        font-size: 0.9rem;
    }
    
    #status_chart {
        height: 250px;
    }
    
    .chart-canvas {
        max-height: 250px;
    }
    
    /* Tighter card spacing */
    .card-body {
        padding: 0.75rem 0.5rem;
    }
    
    .card-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    /* Smaller badges */
    .badge {
        font-size: 0.8rem;
        padding: 0.3rem 0.5rem;
        display: inline-block;
        max-width: 100%;
        white-space: normal;
        word-wrap: break-word;
    }
    
    /* Fix auto-refresh section for small screens */
    .auto-refresh-section {
        margin-top: 10px;
        padding: 6px;
        font-size: 0.75rem;
    }
    
    .auto-refresh-section small {
        line-height: 1.3;
    }
    
    /* Stack chart containers with less margin */
    .chart-container {
        margin-bottom: 10px;
    }
    
    /* Fix text overflow */
    .card-subtitle {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Tank Levels small mobile */
    .btn-group-custom .btn {
        min-width: 90px;
        font-size: 0.8rem;
        padding: 0.5rem 0.6rem;
    }
    
    #chart, #chart2 {
        height: 300px;
    }
    
    /* Extra small calendar adjustments */
    .calendar-view #chart {
        min-height: 350px;
        padding: 5px;
        margin: 0 -10px; /* Extend calendar to screen edges */
    }
    
    /* Calendar statistics - stack vertically on small mobile */
    .calendar-view #average_daily .col-md-3,
    .calendar-view #average_daily .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 6px;
        text-align: center;
    }
    
    #average_daily {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    /* Stack statistics vertically on very small screens */
    #average_daily .row {
        flex-direction: column;
    }
    
    #average_daily .col-md-4,
    #average_daily .col-md-6,
    #average_daily .col-md-3 {
        width: 100%;
        margin-bottom: 8px;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Status indicators */
.status-critical {
    color: var(--danger-color);
}

.status-warning {
    color: var(--warning-color);
}

.status-good {
    color: var(--success-color);
}

/* Utility classes */
.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

/* Print styles */
@media print {
    .chart-container {
        break-inside: avoid;
    }
    
    .alert, .text-muted {
        display: none;
    }
}