/* ============================================
   地產中介網頁資料庫 - 全局樣式文件
   ============================================ */

/* ========== 基礎設置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', '微軟正黑體', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* ========== 容器 ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ========== 卡片樣式 ========== */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 30px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 24px;
    color: #667eea;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

/* ========== 表單元素 ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group input.error,
.form-group select.error {
    border-color: #e74c3c;
}

.form-group .error-message {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 5px;
}

/* ========== 按鈕樣式 ========== */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #219a52;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #d68910;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== 登入頁面 ========== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
    font-size: 28px;
}

.login-box .subtitle {
    text-align: center;
    color: #999;
    margin-bottom: 30px;
    font-size: 14px;
}

.login-box .form-group {
    margin-bottom: 20px;
}

.login-box .btn {
    margin-top: 10px;
}

.login-box .links {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.login-box .links a {
    color: #667eea;
    text-decoration: none;
    margin: 0 10px;
}

.login-box .links a:hover {
    text-decoration: underline;
}

/* ========== 導航欄 ========== */
.navbar {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 15px 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 20px;
    font-weight: bold;
    color: #667eea;
    text-decoration: none;
}

.navbar-menu {
    display: flex;
    gap: 15px;
    align-items: center;
}

.navbar-menu a {
    color: #555;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 5px;
    transition: all 0.3s;
}

.navbar-menu a:hover,
.navbar-menu a.active {
    background: #667eea;
    color: white;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-user span {
    color: #667eea;
    font-weight: bold;
}

/* ========== 主頁網格 ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px;
}

.dashboard-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    transition: all 0.3s;
    text-decoration: none;
    color: #333;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.dashboard-card .icon {
    font-size: 50px;
    margin-bottom: 15px;
}

.dashboard-card h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.dashboard-card p {
    color: #999;
    font-size: 14px;
}

/* ========== 表格樣式 ========== */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.data-table th {
    background: #667eea;
    color: white;
    font-weight: bold;
    position: sticky;
    top: 0;
}

.data-table tr:hover {
    background: #f5f5f5;
}

.data-table tr:nth-child(even) {
    background: #fafafa;
}

.data-table tr:nth-child(even):hover {
    background: #f0f0f0;
}

/* ========== 搜尋結果特殊表格 (三行佈局) ========== */
.listing-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    overflow: hidden;
}

.listing-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border: 1px solid #e0e0e0;
}

.listing-cell {
    padding: 8px;
    border-right: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 13px;
}

/* 固定列 - 第 1,2,3 列藍色背景 */
.listing-cell.fixed-col {
    background: #e8f4f8;
}

/* 第 1 欄打通 - 輸入日期等 */
.listing-cell.col-1-row-1 { grid-column: 1 / 2; grid-row: 1 / 2; }
.listing-cell.col-1-row-2 { grid-column: 1 / 2; grid-row: 2 / 3; }
.listing-cell.col-1-row-3 { grid-column: 1 / 2; grid-row: 3 / 4; }

/* 第 2 欄打通 - 地區大廈等 */
.listing-cell.col-2-row-1 { grid-column: 2 / 3; grid-row: 1 / 2; }
.listing-cell.col-2-row-2 { grid-column: 2 / 3; grid-row: 2 / 3; }
.listing-cell.col-2-row-3 { grid-column: 2 / 3; grid-row: 3 / 4; }

/* 第 3 欄打通 - 實用呎數等 */
.listing-cell.col-3-row-1 { grid-column: 3 / 4; grid-row: 1 / 2; }
.listing-cell.col-3-row-2 { grid-column: 3 / 4; grid-row: 2 / 3; }
.listing-cell.col-3-row-3 { grid-column: 3 / 4; grid-row: 3 / 4; }

/* 第 4 欄打通 - 建築呎數等 */
.listing-cell.col-4-row-1 { grid-column: 4 / 5; grid-row: 1 / 2; }
.listing-cell.col-4-row-2 { grid-column: 4 / 5; grid-row: 2 / 3; }
.listing-cell.col-4-row-3 { grid-column: 4 / 5; grid-row: 3 / 4; }

/* 第 5 欄打通 - 售價租金 */
.listing-cell.col-5-row-1 { grid-column: 5 / 6; grid-row: 1 / 4; }
.listing-cell.col-5-row-1 .price-main { font-size: 18px; font-weight: bold; color: #e74c3c; }
.listing-cell.col-5-row-1 .price-sub { font-size: 12px; color: #999; }

/* 第 6 欄打通 - 聯絡人 */
.listing-cell.col-6-row-1 { grid-column: 6 / 7; grid-row: 1 / 4; }

/* 第 7 欄打通 - 景觀裝修等 */
.listing-cell.col-7-row-1 { grid-column: 7 / 8; grid-row: 1 / 4; }

.listing-cell-label {
    font-size: 11px;
    color: #999;
    margin-bottom: 3px;
}

.listing-cell-value {
    font-size: 13px;
    color: #333;
    font-weight: 500;
}

/* ========== 搜尋篩選器 ========== */
.search-filter {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.search-filter-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.search-filter-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.search-filter-section h4 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 16px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 10px;
}

.filter-item {
    flex: 1;
    min-width: 200px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #f5f5f5;
    padding: 5px 10px;
    border-radius: 5px;
}

.checkbox-item input[type="checkbox"] {
    width: auto;
}

/* ========== 響應式設計 ========== */
@media (max-width: 768px) {
    .navbar-content {
        flex-direction: column;
        gap: 10px;
    }

    .navbar-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .listing-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .listing-cell {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-item {
        min-width: 100%;
    }
}

/* ========== 提示消息 ========== */
.alert {
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* ========== 加載動畫 ========== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== 隱藏元素 ========== */
.hidden {
    display: none !important;
}

/* ========== 頁腳 ========== */
.footer {
    text-align: center;
    padding: 20px;
    color: white;
    margin-top: 40px;
}

/* ========== 工具連結頁面 ========== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.tool-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.1);
}

.tool-card h4 {
    color: #667eea;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.tool-link {
    display: block;
    padding: 10px;
    margin-bottom: 10px;
    background: #f5f5f5;
    border-radius: 5px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s;
}

.tool-link:hover {
    background: #667eea;
    color: white;
    transform: translateX(5px);
}