/* =============================================================================
   RBD Dairy Dashboard - Styles
   ============================================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* =============================================================================
   Login Screen
   ============================================================================= */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 40px;
}

.login-box h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 28px;
}

.login-box > p {
    color: #666;
    margin-bottom: 30px;
}

.login-box input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

.login-box input:focus {
    outline: none;
    border-color: #667eea;
}

.login-box button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.login-box button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.error-message {
    color: #e74c3c;
    margin-top: 15px;
    display: none;
}

/* =============================================================================
   Dashboard Layout
   ============================================================================= */

.dashboard {
    display: none;
    background: #f5f7fa;
    min-height: 100vh;
}

.dashboard.active {
    display: block;
}

/* Header */
.header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.header-left h1 {
    color: #333;
    font-size: 24px;
}

.header-left p {
    color: #666;
    font-size: 14px;
}

.last-update {
    text-align: right;
}

.last-update-label {
    color: #666;
    font-size: 12px;
}

.last-update-time {
    color: #333;
    font-weight: 600;
    font-size: 16px;
}

.settings-btn,
.feedback-btn {
    background: none;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-btn:hover,
.feedback-btn:hover {
    border-color: #667eea;
    background: #f0f0ff;
}

.feedback-btn {
    font-size: 18px;
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* =============================================================================
   Alert Banner
   ============================================================================= */

.alert {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-left: 4px solid #28a745;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border-left-color: #ffc107;
}

.alert.alert-warning .alert-text {
    color: #856404;
}

.alert.alert-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-left-color: #dc3545;
}

.alert.alert-error .alert-text {
    color: #721c24;
}

.alert-icon {
    font-size: 20px;
}

.alert-text {
    color: #155724;
    font-weight: 500;
}

/* =============================================================================
   Metric Cards
   ============================================================================= */

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.metric-label {
    color: #666;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-icon {
    font-size: 20px;
}

.metric-value {
    color: #333;
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 5px;
}

.metric-value.flow-status {
    font-size: 24px;
}

.metric-value.shift-start {
    font-size: 20px;
}

.metric-value.weekly-avg {
    font-size: 28px;
}

.metric-subtitle {
    color: #999;
    font-size: 14px;
}

/* =============================================================================
   Shift Progress
   ============================================================================= */

.shift-progress {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 30px;
}

.shift-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.shift-title h2 {
    color: #333;
    font-size: 24px;
    margin-bottom: 5px;
}

.shift-title p {
    color: #666;
    font-size: 14px;
}

.shift-current {
    text-align: right;
}

.shift-current-value {
    color: #28a745;
    font-size: 42px;
    font-weight: 700;
}

.shift-current-label {
    color: #999;
    font-size: 14px;
}

.progress-bar-container {
    height: 40px;
    background: #f0f0f0;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 20px;
    transition: width 0.5s ease;
    min-width: 60px;
    width: 0%;
}

.progress-text {
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.progress-status {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.status-icon {
    font-size: 16px;
}

/* =============================================================================
   Sections
   ============================================================================= */

.section {
    margin-bottom: 30px;
}

.section-title {
    color: #333;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.large-metric {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.large-metric.wash-metric {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
}

.metric-subtitle-header {
    color: #666;
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 500;
}

.large-metric-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.large-metric-value {
    font-size: 48px;
    font-weight: 700;
    color: #667eea;
}

.large-metric-value.wash-value {
    color: #1976d2;
}

.metric-unit {
    color: #999;
    margin-top: 5px;
}

.large-metric-badge {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-error {
    background: #f8d7da;
    color: #721c24;
}

/* =============================================================================
   Alerts List
   ============================================================================= */

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert-item {
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.alert-item.unacknowledged {
    border-left: 4px solid #ffc107;
}

.alert-item-content {
    flex: 1;
}

.alert-item-title {
    font-weight: 600;
    color: #333;
}

.alert-item-message {
    color: #666;
    font-size: 14px;
    margin-top: 4px;
}

.alert-item-time {
    color: #999;
    font-size: 12px;
}

/* =============================================================================
   Modal
   ============================================================================= */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 20px;
}

.modal-body h3 {
    color: #333;
    margin: 20px 0 15px;
    font-size: 18px;
}

.modal-body h3:first-child {
    margin-top: 0;
}

/* =============================================================================
   Feedback Form
   ============================================================================= */

.feedback-intro {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #333;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.feedback-type-selector {
    display: flex;
    gap: 15px;
}

.feedback-type-option {
    flex: 1;
    cursor: pointer;
}

.feedback-type-option input {
    display: none;
}

.feedback-type-label {
    display: block;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    transition: all 0.2s;
}

.feedback-type-option input:checked + .feedback-type-label.bug {
    border-color: #dc3545;
    background: #f8d7da;
    color: #721c24;
}

.feedback-type-option input:checked + .feedback-type-label.feature {
    border-color: #28a745;
    background: #d4edda;
    color: #155724;
}

.feedback-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
}

.feedback-success {
    text-align: center;
    padding: 20px;
}

.feedback-success .success-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.feedback-success h3 {
    color: #28a745;
    margin-bottom: 10px;
}

.feedback-success p {
    color: #666;
    margin-bottom: 20px;
}

.feedback-success a {
    color: #667eea;
    font-weight: 600;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =============================================================================
   Admin Panel
   ============================================================================= */

.admin-btn {
    background: none;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-btn:hover {
    border-color: #667eea;
    background: #f0f0ff;
}

.modal-large {
    max-width: 800px;
}

.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

.admin-tab {
    background: none;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.admin-tab:hover {
    background: #f0f0f0;
    color: #333;
}

.admin-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.admin-settings-grid {
    display: grid;
    gap: 20px;
}

.setting-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.setting-info {
    flex: 1;
}

.setting-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.setting-description {
    color: #666;
    font-size: 13px;
}

.setting-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-input {
    width: 120px;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-align: right;
    transition: border-color 0.2s;
}

.setting-input:focus {
    outline: none;
    border-color: #667eea;
}

.setting-input.modified {
    border-color: #ffc107;
    background: #fff9e6;
}

.setting-unit {
    color: #666;
    font-size: 14px;
    min-width: 60px;
}

.admin-actions {
    margin-top: 25px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.save-status {
    color: #28a745;
    font-weight: 500;
}

.save-status.error {
    color: #dc3545;
}

.settings-history {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
}

.history-item:last-child {
    border-bottom: none;
}

.history-setting {
    font-weight: 600;
    color: #333;
}

.history-change {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.history-old {
    color: #999;
    text-decoration: line-through;
}

.history-arrow {
    color: #666;
}

.history-new {
    color: #28a745;
    font-weight: 600;
}

.history-time {
    color: #999;
    font-size: 12px;
}

/* =============================================================================
   Weather Section
   ============================================================================= */

.weather-grid {
    display: grid;
    grid-template-columns: 280px 1fr 1fr;
    gap: 20px;
}

.weather-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.weather-card h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 14px;
    font-weight: 600;
}

.current-weather {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.weather-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.weather-temp {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 5px;
}

.weather-conditions {
    font-size: 16px;
    opacity: 0.9;
    margin-bottom: 20px;
}

.weather-details {
    display: flex;
    justify-content: space-around;
    padding: 15px 0;
    border-top: 1px solid rgba(255,255,255,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.2);
    margin-bottom: 15px;
}

.weather-detail {
    text-align: center;
}

.detail-label {
    display: block;
    font-size: 11px;
    opacity: 0.8;
    margin-bottom: 4px;
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
}

.heat-stress-indicator {
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px;
}

.stress-label {
    font-size: 12px;
    opacity: 0.9;
}

.stress-level {
    display: block;
    font-size: 16px;
    font-weight: 700;
    margin-top: 4px;
    text-transform: uppercase;
}

.stress-level.low { color: #90EE90; }
.stress-level.moderate { color: #FFD700; }
.stress-level.high { color: #FFA500; }
.stress-level.extreme { color: #FF4444; }

/* Weather Insights */
.insights-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.insight-item {
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid;
}

.insight-item.info {
    background: #e3f2fd;
    border-color: #2196f3;
}

.insight-item.warning {
    background: #fff3e0;
    border-color: #ff9800;
}

.insight-item.alert {
    background: #ffebee;
    border-color: #f44336;
}

.insight-title {
    font-weight: 600;
    color: #333;
    font-size: 13px;
    margin-bottom: 4px;
}

.insight-message {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
}

.insight-recommendation {
    font-size: 11px;
    color: #888;
    font-style: italic;
}

.insight-placeholder,
.forecast-placeholder {
    color: #999;
    font-size: 14px;
    padding: 20px;
    text-align: center;
}

/* Weather Forecast */
.forecast-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.forecast-day {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.forecast-date {
    font-weight: 600;
    color: #333;
    min-width: 80px;
}

.forecast-temps {
    display: flex;
    gap: 10px;
    font-size: 14px;
}

.forecast-high {
    color: #e53935;
    font-weight: 600;
}

.forecast-low {
    color: #1e88e5;
}

.forecast-conditions {
    color: #666;
    font-size: 13px;
    flex: 1;
    text-align: center;
}

.forecast-stress {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.forecast-stress.low { background: #e8f5e9; color: #2e7d32; }
.forecast-stress.moderate { background: #fff8e1; color: #f57f17; }
.forecast-stress.high { background: #fff3e0; color: #e65100; }
.forecast-stress.extreme { background: #ffebee; color: #c62828; }

@media (max-width: 1024px) {
    .weather-grid {
        grid-template-columns: 1fr 1fr;
    }

    .current-weather {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .weather-grid {
        grid-template-columns: 1fr;
    }

    .current-weather {
        grid-column: span 1;
    }
}

/* =============================================================================
   Charts & Comparisons
   ============================================================================= */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.section-header .section-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

.export-icon {
    margin-right: 5px;
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.comparison-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.comparison-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.12);
}

.comparison-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.comparison-label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.comparison-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.comparison-badge.up {
    background: #d4edda;
    color: #155724;
}

.comparison-badge.down {
    background: #f8d7da;
    color: #721c24;
}

.comparison-badge.flat {
    background: #e2e3e5;
    color: #383d41;
}

.comparison-values {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.comparison-current,
.comparison-previous {
    text-align: center;
    flex: 1;
}

.comparison-vs {
    color: #999;
    font-size: 14px;
    padding: 0 15px;
}

.comparison-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: #333;
}

.comparison-current .comparison-value {
    color: #667eea;
}

.comparison-period {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.comparison-delta {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.comparison-delta .delta-value {
    font-size: 20px;
    font-weight: 700;
}

.comparison-delta.positive .delta-value {
    color: #28a745;
}

.comparison-delta.positive .delta-value::before {
    content: "+";
}

.comparison-delta.negative .delta-value {
    color: #dc3545;
}

.comparison-delta .delta-label {
    color: #666;
    font-size: 13px;
    margin-left: 5px;
}

.chart-controls {
    display: flex;
    gap: 5px;
    background: #f0f0f0;
    padding: 4px;
    border-radius: 8px;
}

.chart-tab {
    background: transparent;
    border: none;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-tab:hover {
    color: #333;
}

.chart-tab.active {
    background: white;
    color: #667eea;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chart-container {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    height: 350px;
    position: relative;
}

.chart-container canvas {
    max-height: 100%;
}

/* =============================================================================
   Mobile Responsive Improvements
   ============================================================================= */

@media (max-width: 768px) {
    .header-right {
        flex-wrap: wrap;
    }

    .comparison-grid {
        grid-template-columns: 1fr;
    }

    .comparison-values {
        flex-direction: column;
        gap: 10px;
    }

    .comparison-vs {
        padding: 5px 0;
    }

    .comparison-value {
        font-size: 24px;
    }

    .chart-controls {
        width: 100%;
        justify-content: center;
    }

    .chart-container {
        height: 280px;
        padding: 15px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-btn,
    .feedback-btn,
    .settings-btn {
        padding: 10px 14px;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
        max-height: 90vh;
    }

    .modal-large {
        max-width: 95%;
    }

    .setting-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .setting-input-wrapper {
        width: 100%;
    }

    .setting-input {
        flex: 1;
    }

    .admin-tabs {
        flex-wrap: wrap;
    }

    .feedback-type-selector {
        flex-direction: column;
    }
}

/* Touch-friendly buttons on mobile */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .chart-tab,
    .admin-tab {
        min-height: 44px;
        min-width: 44px;
    }

    .metric-card,
    .comparison-card {
        cursor: default;
    }

    .metric-card:hover,
    .comparison-card:hover {
        transform: none;
    }
}

/* =============================================================================
   Buttons
   ============================================================================= */

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* =============================================================================
   Footer
   ============================================================================= */

.footer {
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-top: 40px;
}

/* =============================================================================
   Loading States
   ============================================================================= */

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .header-left {
        flex-direction: column;
    }

    .header-right {
        width: 100%;
        justify-content: center;
    }

    .last-update {
        text-align: center;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .metric-value {
        font-size: 28px;
    }

    .shift-header {
        flex-direction: column;
        text-align: center;
    }

    .shift-current {
        text-align: center;
    }

    .shift-current-value {
        font-size: 32px;
    }

    .large-metric-content {
        flex-direction: column;
        text-align: center;
    }

    .large-metric-value {
        font-size: 36px;
    }
}

/* =============================================================================
   Robinhood-Style Flow Chart
   ============================================================================= */

.flow-chart-section {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.flow-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 25px;
}

.flow-chart-value-group {
    display: flex;
    flex-direction: column;
}

.flow-chart-total {
    font-size: 48px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
    letter-spacing: -1px;
}

.flow-chart-unit {
    font-size: 16px;
    color: #666;
    margin-top: 4px;
}

.flow-chart-change {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 16px;
    font-weight: 600;
}

.flow-chart-change.positive {
    color: #00c805;
}

.flow-chart-change.positive .change-value::before {
    content: "+";
}

.flow-chart-change.negative {
    color: #ff5000;
}

.flow-chart-change .change-percent {
    opacity: 0.8;
}

.flow-chart-period-selector {
    display: flex;
    gap: 0;
    background: #f5f5f5;
    border-radius: 25px;
    padding: 4px;
}

.flow-period-btn {
    background: transparent;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.flow-period-btn:hover {
    color: #333;
}

.flow-period-btn.active {
    background: white;
    color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.flow-chart-container {
    height: 350px;
    position: relative;
    margin: 0 -10px;
}

.flow-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.flow-chart-stats {
    display: flex;
    justify-content: space-around;
    padding: 20px 0;
    margin-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.flow-stat {
    text-align: center;
}

.flow-stat-label {
    display: block;
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.flow-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.flow-chart-toggle {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    user-select: none;
}

.toggle-option input {
    display: none;
}

.toggle-indicator {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    transition: opacity 0.2s;
}

.toggle-indicator.flow-rate {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.toggle-indicator.cumulative {
    background: linear-gradient(135deg, #00c805, #00a004);
}

.toggle-option input:not(:checked) + .toggle-indicator {
    opacity: 0.3;
}

/* Hover effect for chart */
.flow-chart-container:hover {
    cursor: crosshair;
}

/* Tooltip styling is handled by Chart.js config */

@media (max-width: 768px) {
    .flow-chart-section {
        padding: 20px;
    }

    .flow-chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .flow-chart-total {
        font-size: 36px;
    }

    .flow-chart-period-selector {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .flow-period-btn {
        padding: 8px 14px;
        font-size: 13px;
        flex: 1;
        text-align: center;
    }

    .flow-chart-container {
        height: 280px;
    }

    .flow-chart-stats {
        flex-wrap: wrap;
        gap: 20px;
    }

    .flow-stat {
        flex: 1 1 100px;
    }

    .flow-chart-toggle {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
}

/* =============================================================================
   Production Intelligence Section
   ============================================================================= */

.intelligence-section {
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border-radius: 16px;
    padding: 25px;
}

.intelligence-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.intel-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.intel-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.intel-card.wide-card {
    grid-column: span 2;
}

.intel-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.intel-icon {
    font-size: 20px;
}

.intel-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.intel-card-body {
    text-align: center;
    padding: 10px 0;
}

.intel-main-value {
    font-size: 36px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.1;
}

.intel-unit {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
    margin-bottom: 15px;
}

.intel-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid #f5f5f5;
}

.intel-label {
    font-size: 13px;
    color: #888;
}

.intel-value {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.intel-card-footer {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    font-size: 12px;
    color: #888;
    text-align: center;
}

/* Card-specific colors */
.projection-card .intel-main-value {
    color: #667eea;
}

.revenue-card .intel-main-value {
    color: #28a745;
}

.performance-card .intel-main-value {
    color: #17a2b8;
}

.weather-impact-card .intel-main-value {
    color: #fd7e14;
}

.trends-card .intel-main-value {
    color: #6f42c1;
}

/* Status indicators */
.intel-card-footer.status-ahead {
    color: #28a745;
    font-weight: 600;
}

.intel-card-footer.status-on-track {
    color: #17a2b8;
    font-weight: 600;
}

.intel-card-footer.status-behind {
    color: #dc3545;
    font-weight: 600;
}

/* Value colors for positive/negative */
.intel-value.positive {
    color: #28a745;
}

.intel-value.negative {
    color: #dc3545;
}

.intel-value.neutral {
    color: #6c757d;
}

/* Recommendations list */
.recommendations-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.recommendations-list li {
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.recommendations-list li:last-child {
    border-bottom: none;
}

.recommendations-list li::before {
    content: "\2022";
    color: #667eea;
    font-weight: bold;
    font-size: 18px;
    line-height: 1;
}

.recommendations-card .intel-card-body {
    text-align: left;
    padding: 5px 0;
}

/* Trend direction indicators */
.trend-up {
    color: #28a745;
}

.trend-up::before {
    content: "\2191 ";
}

.trend-down {
    color: #dc3545;
}

.trend-down::before {
    content: "\2193 ";
}

.trend-stable {
    color: #6c757d;
}

.trend-stable::before {
    content: "\2194 ";
}

/* Responsive */
@media (max-width: 768px) {
    .intelligence-grid {
        grid-template-columns: 1fr;
    }

    .intel-card.wide-card {
        grid-column: span 1;
    }

    .intel-main-value {
        font-size: 28px;
    }

    .intelligence-section {
        padding: 15px;
    }
}

@media (max-width: 1200px) {
    .intel-card.wide-card {
        grid-column: span 1;
    }
}

/* =============================================================================
   Alert Settings
   ============================================================================= */

.tab-description {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-settings-grid {
    display: grid;
    gap: 15px;
}

.setting-card-full {
    flex-direction: column;
    align-items: stretch;
}

.setting-card-full .setting-info {
    margin-bottom: 10px;
}

.setting-card-full .setting-input-wrapper {
    width: 100%;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #667eea;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 1px #667eea;
}

/* Save status styles */
.save-status.success {
    color: #2e7d32;
}

.save-status.error {
    color: #c62828;
}
