:root {
    --bg-color: #f4f6f8;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --border-radius: 12px;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --status-green: #52c41a;
    --status-red: #ff4d4f;
    --status-orange: #fa8c16;
    --status-gray: #8c8c8c;
}

body {
    font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 1.5rem 1.5rem 90px 1.5rem;
    display: flex;
    justify-content: center;
    /* Smooth transition for dynamic background colour changes */
    transition: background-color 0.4s ease;
}

/* Dynamic Alert Level Backgrounds */
body.bg-sharp-green {
    background-color: #00db49d8 !important;
}

body.bg-sharp-orange {
    background-color: #ff8e0cda !important;
}

body.bg-sharp-red {
    background-color: #f31717d5 !important;
}

.container {
    width: 100%;
    max-width: 900px;
}

header {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

h1 { font-size: 1.8rem; margin: 0; }

.header-status-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.status-badge {
    font-size: 0.85rem;
    color: #6c757d;
    background: #e9ecef;
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.status-dot.online {
    background-color: var(--status-green);
    box-shadow: 0 0 6px rgba(82, 196, 26, 0.6);
}

.status-dot.offline {
    background-color: var(--status-red);
    box-shadow: 0 0 6px rgba(255, 77, 79, 0.6);
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.record-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    /* Flexbox split: left and right */
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.0rem;
}

.record-card.alert-none { border-left: 6px solid #6c757d; }
.record-card.alert-low {
  border-left: 8px solid var(--status-gray);
  background-color: #f8f9fa;
  color: #4a4a4a;
  font-size: 1.5rem;
}
.record-card.alert-medium {
    background-color: #fffbe6;
    border: 2px solid #ffe58f;
    border-left: 8px solid var(--status-orange);
    font-size: 1.7rem;
}
.record-card.alert-high {
    background-color: #ffe6e6;
    border: 2px solid #ffccc7;
    border-left: 8px solid var(--status-red);
    font-size: 1.7rem;
}
.record-card.alert-high > .record-text { font-weight: 600; text-decoration: underline; }

/* Left Side: Text content */
.record-right {
    flex: 1;
}

.record-text { 
    white-space: pre-line; 
    line-height: 1.6; 
}

.record-card.alert-high .record-text { 
    font-weight: 600; 
    text-decoration: underline; 
}

/* Right Side: Split Up (Time) and Down (Logo) */
.record-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-width: 20px;
    gap: 0.25rem;
}

.record-timestamp {
    font-size: 1.2rem;
    color: #555;
    white-space: nowrap;
}

.record-logo-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.record-logo {
    max-height: 36px;
    width: auto;
    object-fit: contain;
}

.record-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.75rem;
}

.record-text { white-space: pre-line; line-height: 1.6; }

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    margin: 5px;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show { opacity: 1; transform: translateX(0);}
.toast-error { background-color: var(--status-red); color: #ffffff; }
.toast-success { background-color: var(--status-green); color: #ffffff; }

/* Audio Notification Base Styles */
.audio-toast {
    position: fixed;
    bottom: 95px; /* Keeps the toast clear of the fixed bottom footer */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    max-width: 90vw;
    width: max-content;
    padding: 10px 20px;
    border-radius: 24px;
    
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Banner variant (warning state) */
.audio-toast-banner {
    background-color: #faad14;
    color: #ffffff;
    cursor: pointer;
}

.audio-toast-banner:active {
    transform: translateX(-50%) scale(0.97);
}

/* Unlocked pop-up variant (grey state) */
.audio-toast-unlocked {
    background-color: #4a4a4a;
    color: #ffffff;
    opacity: 0;
}

.audio-toast-unlocked.show {
    opacity: 1;
}

/* Desktop Viewport Adjustments (min-width: 768px) */
@media (max-width: 1024px) {
    .audio-toast {
        bottom: 105px;
        font-size: 1.1rem;
        padding: 12px 24px;
    }
}

/* Small Mobile Viewport Adjustments (max-width: 480px) */
@media (max-width: 600px) {
    .audio-toast {
        bottom: 150px;
        font-size: 1rem;
        padding: 8px 16px;
        border-radius: 20px;
        white-space: normal; /* Allows clean text wrapping if device width is narrow */
    }
}

/* Loading spinner adjacent to fetch timestamp */
.fetch-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: #1890ff; /* Adjust to match your theme color */
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #fffbe6; /* Pale yellow */
    border-top: 1px solid #ffe58f;
    padding: 0.6rem 1rem;
    text-align: center;
    color: #2c3e50;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    z-index: 999;
    box-sizing: border-box;
    line-height: 1.4;
}

.footer-reminder {
    margin: 0 0 0.3rem 0;
    font-weight: 600;
    font-size: 1.25rem;
    color: #2c3e50;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.3rem 0.6rem;
}

.footer-hotlines {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem 0.6rem;
}

.hotline-item {
    white-space: nowrap;
}

.hotline-divider {
    color: #cca200;
    font-weight: 300;
}

.phone-link {
    color: #0056b3;
    text-decoration: none;
}

.phone-link:hover {
    text-decoration: underline;
}

.footer-copyright {
    margin: 0;
    font-size: 1rem;
    color: #595959;
}

/* Tablet */
@media (max-width: 1024px) {
    body { padding: 1rem 1rem 120px 1rem; }
    .record-card { padding: 1rem; }    
    .record-card.alert-low { font-size: 1.7rem; }
    .record-card.alert-medium, .record-card.alert-high { font-size: 2.2rem; }
    .record-timestamp { font-size: 1.5rem; }    
    .status-badge, .record-meta, .toast { font-size: 0.8rem; }
    .record-logo {max-height: 50px; gap: 0.4rem;}

    .app-footer {
        padding: 0.6rem 0.6rem;
    }
    .footer-reminder {
        font-size: 1.2rem;
    }
    .footer-copyright {
        font-size: 1rem;
    }
    .hotline-divider {
        display: none; /* Hide vertical divider on narrow screens to stack cleanly */
    }
    .footer-hotlines {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
    }
    .footer-copyright {
        font-size: 0.75rem;
        margin-top: 0.2rem;
    }
}

/* Phone */
@media (max-width: 600px) {
    body { padding: 0.75rem 0.75rem 150px 0.75rem; }      
    .record-card { padding: 0.85rem 1rem; }    
    /* .record-card.alert-low { font-size: 1.05rem; }
    .record-card.alert-medium, .record-card.alert-high { font-size: 1.15rem; } */
    .record-timestamp { font-size: 1.5rem; }
    .status-badge, .record-meta, .toast { font-size: 0.75rem; }
    .record-logo {max-height: 30px; gap: 0.3rem;}
    .record-card {
        display: flex;
        flex-direction: column;
        padding: 12px 16px;
        margin-bottom: 10px;
        background: #ffffff;
        border-radius: 12px;
        gap: 0.25rem;
    }

    /* Header Row inside Card */
    .record-left {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        /* margin-bottom: 8px; */
        width: 100%;
    }
    .footer-hotlines {
        align-items: center;
    }
}
