:root {
    --bg-color: #f5f7fb;
    --text-color: #111827;
    --panel-bg: rgba(255, 255, 255, 0.92);
    --panel-border: rgba(148, 163, 184, 0.24);
    --primary: #2563eb;
    --secondary: #e2e8f0;
    --danger: #c0392b;
    --warning: #e67e22;
    --success: #16a34a;
    --surface-light: #ffffff;
    --text-muted: #64748b;
    --dot-size: 18px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

hr {
    border: none;
    border-top: 1px solid var(--panel-border);
    margin: 20px 0;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.title-section h1 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.title-section p {
    color: #aaaaaa;
    font-size: 0.9rem;
}

.location-section {
    display: flex;
    gap: 15px;
}

.select-group {
    display: flex;
    flex-direction: column;
}

.select-group label {
    font-size: 0.85rem;
    color: #475569;
    margin-bottom: 5px;
}

select {
    padding: 8px 12px;
    border-radius: 6px;
    background-color: var(--secondary);
    color: #111827;
    border: 1px solid var(--panel-border);
    outline: none;
    font-size: 1rem;
    cursor: pointer;
}

/* Ensure options have solid light background on Windows */
select option {
    background-color: var(--secondary);
    color: #111827;
}

/* Chat Section */
.chat-section h3 {
    margin-bottom: 15px;
}

.chat-container {
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.95);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-history {
    height: 350px;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
}

.message img {
    max-width: 200px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: block;
}

.user-message {
    align-self: flex-end;
    background-color: var(--secondary);
    color: #111827;
    border-bottom-right-radius: 2px;
}

.assistant-message {
    align-self: flex-start;
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-bottom-left-radius: 2px;
    color: #111827;
}

.chat-input-area {
    display: flex;
    padding: 15px;
    background-color: var(--panel-bg);
    border-top: 1px solid var(--panel-border);
    align-items: center;
    gap: 10px;
}

.upload-btn {
    cursor: pointer;
    font-size: 1.2rem;
    color: #aaa;
    transition: color 0.2s;
}

.upload-btn:hover {
    color: var(--text-color);
}

.file-name {
    font-size: 0.8rem;
    color: var(--primary);
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#chat-input {
    flex-grow: 1;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    background-color: rgba(255, 255, 255, 0.95);
    color: #111827;
    outline: none;
}

#send-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: transform 0.1s;
}

#send-btn:active {
    transform: scale(0.95);
}

#chat-input {float:left;margin-top:6px;margin-right:10px;width:400px;height:24px;}

#stt_btn {float:left;width:40px;height:40px;line-height:40px;}
.stt_btn_rec  {width:100%;height:100%;border:1px #666 solid;border-radius:40px;}
.stt_btn_stop {width:100%;height:100%;border:1px #666 solid;border-radius:40px;display:none;}
.stt_btn_icon {margin-left:10%;margin-top:10%;height:80%;}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 30px;
}

@media (max-width: 900px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Alerts Section */
.alerts-section h2, .weather-section h2 {
    margin-bottom: 10px;
}

.alerts-card {
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 20px;
    background-color: var(--panel-bg);
}

.alert-status {
    color: #aaa;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.alert-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.alert-btn {
    padding: 10px 5px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: transform 0.15s, filter 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.alert-btn small {
    display: block;
    font-size: 0.8rem;
    opacity: 0.8;
}

.active-alerts-summary {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.summary-item {
    background: var(--surface-light);
    border-left: 4px solid var(--danger);
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
}

.summary-item h4 {
    margin: 0 0 5px 0;
    color: var(--text-color);
    font-size: 1rem;
}

.summary-item p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* 警報詳細資訊 */
.alert-btn:hover {
    transform: scale(1.03);
    filter: brightness(1.2);
}

.ncdr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: #ffffff;
    color: #1f2937;
}

.ncdr-table th {
    background: #e2efff;
    color: #1d4ed8;
    padding: 8px;
    border: 1px solid #d1d5db;
    text-align: center;
    white-space: nowrap;
}

.ncdr-table td {
    padding: 10px;
    border: 1px solid #d1d5db;
    color: #1f2937;
    font-size: 0.95rem;
}

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

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #3498db;
    animation: spin 1s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}



.alert-active {
    color: #111827;
}

.alert-inactive {
    background-color: #e5e7eb;
    color: #6b7280;
}

/* Alert Detail */
.alert-detail {
    margin-top: 20px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 20px;
    background-color: var(--panel-bg);
}

.hidden {
    display: none !important;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

#close-detail {
    background: none;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
}

#close-detail:hover {
    background: #f1f5f9;
}

/* Weather Section */
.weather-caption {
    color: #475569;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.weather-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.wx-card {
    background: var(--panel-bg);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    border: 1px solid var(--panel-border);
}

.wx-label {
    font-size: 0.9rem;
    color: #475569;
    margin-bottom: 8px;
    font-weight: 600;
}

.wx-label small {
    color: #64748b;
    font-weight: normal;
}

.wx-value {
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.wx-sub {
    font-size: 1.05rem;
    margin-top: 5px;
    opacity: 0.85;
}

.wx-sub2 {
    font-size: 0.85rem;
    margin-top: 3px;
    opacity: 0.65;
}

.dot {
    display: inline-block;
    width: var(--dot-size);
    height: var(--dot-size);
    border-radius: 50%;
}

.badge {
    background: #e2e8f0;
    color: #1e293b;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 0.82em;
    margin-left: 5px;
}

.alert-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--panel-border);
}
.alert-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
