/* 基本樣式 */
body {
    font-family: Arial, sans-serif;
    margin: 20px;
    background-color: #f5f5f5;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

/* 查詢表單樣式 */
.query-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

select, input[type="date"], input[type="text"], button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

/* 車格搜尋框樣式 */
#parkingSpaceSearch {
    background-color: white;
    border: 2px solid #ddd;
    transition: border-color 0.3s;
}

#parkingSpaceSearch:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

/* 車格選擇下拉選單樣式 */
#parkingSpaceSelect {
    max-width: 300px;
    height: auto !important;
}

#parkingSpaceSelect option {
    padding: 4px;
    border-bottom: 1px solid #eee;
}

#parkingSpaceSelect option:hover {
    background-color: #e9ecef;
}

/* 按鈕樣式 */
button {
    background: #007bff;
    color: white;
    cursor: pointer;
    border: none;
    min-width: 80px;
    transition: background-color 0.3s;
}

button:hover {
    background: #0056b3;
}

button:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.stop-btn {
    background: #dc3545;
}

.stop-btn:hover:not(:disabled) {
    background: #c82333;
}

/* 狀態顯示樣式 */
.status {
    margin: 10px 0;
    padding: 12px;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
    animation: fadeIn 0.3s;
}

.status.loading {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status.loading::before {
    content: "⏳ ";
}

.status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status.success::before {
    content: "✅ ";
}

.status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status.error::before {
    content: "❌ ";
}

/* 資料資訊樣式 */
.data-info {
    background: #e9ecef;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

#recordCount {
    font-weight: bold;
    color: #495057;
}

.auto-load-info {
    font-size: 14px;
    color: #6c757d;
    font-style: italic;
}

/* 表格容器樣式 */
.table-container {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #ddd;
    max-height: 70vh;
    overflow-y: auto;
}

/* 表格樣式 */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 1200px;
}

th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    font-size: 12px;
    white-space: nowrap;
}

th {
    background-color: #f8f9fa;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid #007bff;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

tr:hover:not(.no-data):not(.loading-row) {
    background-color: #e8f4f8;
    transition: background-color 0.2s;
}

.loading-row {
    background: #fff3cd !important;
    text-align: center;
    font-style: italic;
    animation: pulse 1.5s infinite;
}

.no-data {
    text-align: center;
    color: #666;
    font-style: italic;
    background-color: #f8f9fa;
}

/* 動畫效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .query-form {
        grid-template-columns: 1fr;
    }

    .container {
        margin: 10px;
        padding: 15px;
    }

    .data-info {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    th, td {
        font-size: 10px;
        padding: 4px;
    }

    button {
        width: 100%;
    }
}

/* 場地選擇特殊樣式 */
#siteSelect option:disabled {
    color: #999;
    font-style: italic;
}

/* 搜尋結果提示 */
.search-info {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
    font-style: italic;
}

/* 無搜尋結果樣式 */
.no-results {
    color: #dc3545;
    font-style: italic;
    text-align: center;
    padding: 10px;
}

.highlight {
    background-color: yellow !important;
    color: red;
}

/* 過濾選項樣式 */
.filter-options {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    margin: 0;
    font-weight: normal;
    white-space: nowrap;
}

.filter-group input[type="checkbox"] {
    margin: 0;
}

/* 改善查詢按鈕佈局 */
.form-buttons {
    display: flex;
    gap: 25px;
    flex-direction: row;
}

.form-buttons button {
    flex: 0 0 auto;
    min-width: 80px;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .filter-options {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-group {
        width: 100%;
    }
}
