/**
 * CDRRMO Real-Time Monitoring Widgets Styles
 * Inspired by Bulacan PDRRMO design patterns
 *
 * @version 1.0.0
 */

/* ============================================================
   CONTAINER & GRID LAYOUT
   ============================================================ */

.monitoring-widgets-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.95), rgba(15, 23, 42, 0.98));
    border-radius: 12px;
    border: 1px solid rgba(0, 168, 232, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin-bottom: 1.5rem;
}

.monitoring-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

@media (max-width: 1200px) {
    .monitoring-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .monitoring-grid {
        grid-template-columns: 1fr;
    }

    .monitoring-widgets-container {
        padding: 0.75rem;
        border-radius: 8px;
    }
}

/* ============================================================
   SECTION STYLES
   ============================================================ */

.monitoring-section {
    background: rgba(30, 41, 59, 0.8);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(90deg, rgba(0, 168, 232, 0.2), transparent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
    flex: 1;
}

.section-icon {
    font-size: 1.2rem;
}

.live-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    background: #22c55e;
    color: white;
    border-radius: 4px;
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.status-badge.online {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    background: #00a8e8;
    color: white;
    border-radius: 4px;
}

.widget-content {
    padding: 0.75rem;
    max-height: 280px;
    overflow-y: auto;
}

/* Custom scrollbar */
.widget-content::-webkit-scrollbar {
    width: 4px;
}

.widget-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.widget-content::-webkit-scrollbar-thumb {
    background: rgba(0, 168, 232, 0.5);
    border-radius: 2px;
}

/* ============================================================
   RIVER GAUGE WIDGET
   ============================================================ */

.river-gauge-card {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-left: 4px solid #22c55e;
    transition: all 0.3s ease;
}

.river-gauge-card:last-child {
    margin-bottom: 0;
}

.river-gauge-card.alert {
    border-left-color: #eab308;
    background: rgba(234, 179, 8, 0.1);
}

.river-gauge-card.alarm {
    border-left-color: #f97316;
    background: rgba(249, 115, 22, 0.15);
}

.river-gauge-card.critical {
    border-left-color: #dc2626;
    background: rgba(220, 38, 38, 0.2);
    animation: pulse-danger 1.5s infinite;
}

@keyframes pulse-danger {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

.gauge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.station-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
}

.status-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
}

.status-badge.normal { background: #22c55e; color: white; }
.status-badge.alert { background: #eab308; color: #1e293b; }
.status-badge.alarm { background: #f97316; color: white; }
.status-badge.critical { background: #dc2626; color: white; }

.gauge-visual {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.gauge-bar {
    width: 24px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.gauge-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease, background 0.3s ease;
}

.gauge-markers {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
}

.gauge-markers .marker {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
}

.gauge-markers .marker.critical { background: rgba(220, 38, 38, 0.5); }
.gauge-markers .marker.alarm { background: rgba(249, 115, 22, 0.5); }
.gauge-markers .marker.alert { background: rgba(234, 179, 8, 0.5); }

.gauge-value {
    text-align: center;
}

.level-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #f8fafc;
}

.level-unit {
    display: block;
    font-size: 0.7rem;
    color: #94a3b8;
}

.gauge-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #94a3b8;
}

.trend.rising { color: #f97316; }
.trend.falling { color: #22c55e; }
.trend.stable { color: #94a3b8; }
.trend.rapid_rise { color: #dc2626; font-weight: 700; }

.gauge-action {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.action-text {
    font-size: 0.7rem;
    color: #fbbf24;
    font-weight: 600;
}

/* ============================================================
   RAINFALL STATION WIDGET
   ============================================================ */

.rainfall-card {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.rainfall-card:last-child {
    margin-bottom: 0;
}

.rainfall-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.rainfall-header .station-name {
    font-size: 0.75rem;
}

.intensity-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    color: white;
}

.rainfall-data {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.current-rate {
    text-align: center;
    min-width: 60px;
}

.rate-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: #00a8e8;
}

.rate-unit {
    display: block;
    font-size: 0.6rem;
    color: #94a3b8;
}

.accumulation-grid {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.accum-item {
    flex: 1;
    text-align: center;
    padding: 0.25rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.accum-label {
    display: block;
    font-size: 0.6rem;
    color: #64748b;
    margin-bottom: 0.15rem;
}

.accum-value {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
}

.accum-value.warning { color: #eab308; }
.accum-value.alarm { color: #f97316; }
.accum-value.critical { color: #dc2626; font-weight: 700; }

.rainfall-description {
    margin-top: 0.5rem;
    font-size: 0.65rem;
    color: #94a3b8;
    font-style: italic;
}

/* ============================================================
   TIDE SCHEDULE WIDGET
   ============================================================ */

.tide-display {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.75rem;
}

@media (max-width: 480px) {
    .tide-display {
        grid-template-columns: 1fr;
    }
}

.tide-today h4,
.tide-tomorrow h4 {
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 0 0 0.5rem 0;
    font-weight: 500;
}

.tide-times {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.tide-times.compact {
    gap: 0.25rem;
}

.tide-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 0.75rem;
}

.tide-item.high {
    border-left: 3px solid #00a8e8;
}

.tide-item.low {
    border-left: 3px solid #64748b;
}

.tide-icon {
    font-size: 0.8rem;
}

.tide-type {
    font-weight: 600;
    color: #e2e8f0;
    min-width: 35px;
}

.tide-time {
    color: #00a8e8;
    font-weight: 600;
}

.tide-height {
    margin-left: auto;
    color: #94a3b8;
    font-size: 0.7rem;
}

.sun-times {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: #94a3b8;
}

.storm-surge-status {
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
}

.surge-label {
    color: #94a3b8;
}

.surge-level {
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-weight: 700;
    color: white;
    font-size: 0.65rem;
}

.surge-description {
    color: #e2e8f0;
    flex: 1;
    min-width: 150px;
}

.storm-surge-status.extreme {
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid #dc2626;
    animation: pulse-danger 1.5s infinite;
}

/* ============================================================
   EMERGENCY HOTLINES WIDGET
   ============================================================ */

.hotlines-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

@media (max-width: 400px) {
    .hotlines-grid {
        grid-template-columns: 1fr;
    }
}

.hotline-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.hotline-card:hover {
    background: rgba(0, 168, 232, 0.2);
    border-color: rgba(0, 168, 232, 0.3);
    transform: translateX(4px);
}

.hotline-card.primary {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.2), rgba(185, 28, 28, 0.2));
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.hotline-card.primary:hover {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.3), rgba(185, 28, 28, 0.3));
}

.hotline-icon {
    font-size: 1.2rem;
}

.hotline-info {
    display: flex;
    flex-direction: column;
}

.hotline-name {
    font-size: 0.65rem;
    color: #94a3b8;
}

.hotline-number {
    font-size: 0.85rem;
    font-weight: 700;
    color: #f8fafc;
}

.hotline-card.primary .hotline-number {
    color: #fca5a5;
}

.operations-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse-live 2s infinite;
}

.status-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: #22c55e;
}

/* ============================================================
   FOOTER & CONTROLS
   ============================================================ */

.monitoring-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.last-update {
    font-size: 0.7rem;
    color: #64748b;
}

.last-update span {
    color: #94a3b8;
}

.refresh-btn {
    padding: 0.4rem 0.75rem;
    background: rgba(0, 168, 232, 0.2);
    border: 1px solid rgba(0, 168, 232, 0.3);
    border-radius: 5px;
    color: #00a8e8;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover:not(:disabled) {
    background: rgba(0, 168, 232, 0.3);
    transform: translateY(-1px);
}

.refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   ERROR STATE
   ============================================================ */

.monitoring-error {
    text-align: center;
    padding: 2rem;
    color: #94a3b8;
}

.error-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.monitoring-error p {
    margin: 0 0 1rem 0;
}

.retry-btn {
    padding: 0.5rem 1rem;
    background: #00a8e8;
    border: none;
    border-radius: 5px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.retry-btn:hover {
    background: #0284c7;
}

/* ============================================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .live-badge,
    .status-indicator,
    .river-gauge-card.critical,
    .storm-surge-status.extreme {
        animation: none;
    }

    .gauge-fill,
    .hotline-card,
    .refresh-btn {
        transition: none;
    }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
    .monitoring-widgets-container {
        background: white;
        border: 1px solid #ccc;
        box-shadow: none;
    }

    .monitoring-section {
        background: #f8f9fa;
    }

    .refresh-btn {
        display: none;
    }

    .hotline-card {
        background: #f8f9fa;
        border: 1px solid #ddd;
    }
}

/* ============================================================
   SUBSCRIPTION PANEL STYLES
   ============================================================ */

.subscription-panel {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto 1.5rem;
    padding: 0 1rem;
}

.subscription-card {
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.95), rgba(15, 23, 42, 0.98));
    border-radius: 12px;
    border: 1px solid rgba(0, 168, 232, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.subscription-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(90deg, rgba(0, 168, 232, 0.2), transparent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.subscription-icon {
    font-size: 2rem;
    filter: grayscale(0.5);
}

.subscription-icon.active {
    filter: none;
    animation: pulse-bell 2s infinite;
}

@keyframes pulse-bell {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.subscription-title h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #e2e8f0;
}

.subscription-title p {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: #94a3b8;
}

.subscribed-badge {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    background: #22c55e;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 4px;
}

/* Subscription Form */
.subscription-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 0.5rem;
}

.form-group input[type="email"],
.form-group input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #f1f5f9;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #00a8e8;
}

.form-hint {
    display: block;
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 0.35rem;
}

/* Barangay Selector */
.barangay-selector {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.barangay-search {
    padding: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.barangay-search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 4px;
    color: #f1f5f9;
    font-size: 0.8rem;
}

.barangay-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.25rem;
    padding: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.barangay-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #94a3b8;
    transition: background 0.2s ease;
}

.barangay-option:hover {
    background: rgba(0, 168, 232, 0.1);
}

.barangay-option input:checked + span {
    color: #00a8e8;
    font-weight: 600;
}

/* Alert Types Grid */
.alert-types-grid,
.channels-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.alert-type-option,
.channel-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #94a3b8;
    transition: all 0.2s ease;
}

.alert-type-option:hover,
.channel-option:hover {
    border-color: rgba(0, 168, 232, 0.3);
}

.alert-type-option input:checked + span,
.channel-option input:checked + span {
    color: #00a8e8;
}

.channel-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Subscribe Button */
.subscribe-btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #00a8e8, #0077b6);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.subscribe-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 168, 232, 0.4);
}

.subscribe-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Subscribed State */
.subscription-card.subscribed .subscription-header {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.2), transparent);
}

.subscription-details {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.detail-item {
    display: flex;
    gap: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.detail-item:last-child {
    margin-bottom: 0;
}

.detail-label {
    color: #64748b;
    min-width: 100px;
}

.detail-value {
    color: #e2e8f0;
}

.subscription-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    flex-wrap: wrap;
}

.edit-btn,
.unsubscribe-btn,
.test-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-btn {
    background: rgba(0, 168, 232, 0.2);
    border: 1px solid rgba(0, 168, 232, 0.3);
    color: #00a8e8;
}

.unsubscribe-btn {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #f87171;
}

.test-btn {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

.edit-btn:hover,
.unsubscribe-btn:hover,
.test-btn:hover {
    transform: translateY(-1px);
}

/* Toast Notifications */
.subscription-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: rgba(30, 41, 59, 0.95);
    border-radius: 8px;
    border-left: 4px solid #00a8e8;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    animation: slide-in-toast 0.3s ease;
}

.subscription-toast.success { border-left-color: #22c55e; }
.subscription-toast.error { border-left-color: #dc2626; }
.subscription-toast.warning { border-left-color: #f59e0b; }

.subscription-toast.fade-out {
    animation: fade-out-toast 0.3s ease forwards;
}

@keyframes slide-in-toast {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fade-out-toast {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast-icon { font-size: 1.2rem; }
.toast-message { color: #e2e8f0; font-size: 0.85rem; }

/* Responsive */
@media (max-width: 768px) {
    .subscription-panel {
        padding: 0 0.75rem;
    }

    .subscription-form {
        padding: 1rem;
    }

    .barangay-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .subscription-actions {
        flex-direction: column;
    }

    .edit-btn,
    .unsubscribe-btn,
    .test-btn {
        width: 100%;
        text-align: center;
    }
}
