/* 全局樣式 - 基於明湖童軍團徽設計 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 從團徽提取的色彩系統 */
    --primary-blue: #1e3a6f;        /* 深藍色 - 主色調 */
    --primary-gold: #d4a017;        /* 金黃色 - 強調色 */
    --accent-red: #c41e3a;          /* 紅色 - 點綴色 */
    --accent-orange: #ff7f00;       /* 橙色 - 活力色 */
    --light-blue: #4a7ba7;          /* 淺藍色 */
    --cream: #fef6e4;               /* 奶油色 - 背景 */
    --text-dark: #2c3e50;           /* 深色文字 */
    --text-light: #6c757d;          /* 淺色文字 */
    --border-color: #d4d4d4;        /* 邊框顏色 */
}

body {
    font-family: 'Microsoft JhengHei', '微軟正黑體', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: linear-gradient(135deg, var(--cream) 0%, #f9f5eb 100%);
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    box-shadow: 0 4px 20px rgba(30, 58, 111, 0.1);
    border-radius: 12px;
    margin-top: 20px;
    margin-bottom: 20px;
    border-top: 4px solid var(--primary-blue);
}

/* 標題區域 */
header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--primary-gold);
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background-color: var(--accent-red);
}

header h1 {
    color: var(--primary-blue);
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.05);
}

header p {
    color: var(--text-light);
    font-size: 1.1em;
}

/* 用戶資訊顯示 */
.user-info {
    background: linear-gradient(135deg, rgba(212, 160, 23, 0.08) 0%, rgba(30, 58, 111, 0.05) 100%);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-gold);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.user-info h3 {
    color: var(--primary-blue);
    margin-bottom: 12px;
    font-weight: 600;
}

.user-info p {
    margin-bottom: 8px;
    color: var(--text-dark);
}

.user-info p strong {
    color: var(--primary-blue);
}

/* 表單樣式 */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-blue);
}

.required {
    color: var(--accent-red);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    background-color: white;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(30, 58, 111, 0.1);
}

/* 器材項目樣式 */
.equipment-section h3 {
    color: var(--primary-blue);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-gold);
    padding-bottom: 10px;
    font-weight: 600;
}

.equipment-item {
    background: linear-gradient(135deg, rgba(212, 160, 23, 0.03) 0%, rgba(30, 58, 111, 0.02) 100%);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 2px solid #e8e8e8;
    position: relative;
    transition: all 0.3s ease;
}

.equipment-item:hover {
    border-color: var(--primary-gold);
    box-shadow: 0 4px 12px rgba(30, 58, 111, 0.08);
}

.equipment-item .form-group {
    display: inline-block;
    width: 45%;
    margin-right: 5%;
    vertical-align: top;
}

.equipment-item .form-group:last-of-type {
    margin-right: 0;
}

.add-item-section {
    text-align: center;
    margin: 20px 0;
}

/* 按鈕樣式 - 童軍風格 */
.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--light-blue) 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #152b52 0%, var(--primary-blue) 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--primary-gold) 0%, #c79100 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #c79100 0%, #b58600 100%);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red) 0%, #a01829 100%);
    color: white;
    padding: 8px 16px;
    font-size: 14px;
    position: absolute;
    top: 10px;
    right: 10px;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #a01829 0%, #7d0f1f 100%);
}

/* 表單動作區域 */
.form-actions {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.form-actions .btn {
    margin: 0 10px;
}

/* 模態框樣式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(30, 58, 111, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    padding: 35px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(30, 58, 111, 0.25);
    text-align: center;
    max-width: 400px;
    width: 90%;
    border-top: 4px solid var(--primary-gold);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { 
        transform: translateY(30px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h3 {
    color: var(--primary-blue);
    margin-bottom: 15px;
    font-weight: 600;
}

.modal-content p {
    margin-bottom: 20px;
    color: var(--text-dark);
}

/* 載入動畫 - 童軍色彩 */
.spinner {
    border: 4px solid rgba(212, 160, 23, 0.2);
    border-top: 4px solid var(--primary-gold);
    border-right: 4px solid var(--primary-blue);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    margin: 20px auto;
}

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

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .equipment-item .form-group {
        width: 100%;
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .form-actions .btn {
        display: block;
        width: 100%;
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .container {
        margin: 5px;
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    select {
        font-size: 16px; /* 防止iOS縮放 */
    }
}

/* 錯誤提示樣式 */
.error {
    border-color: var(--accent-red) !important;
    box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.15) !important;
}

.error-message {
    color: var(--accent-red);
    font-size: 14px;
    margin-top: 5px;
    display: block;
}

/* 借用清單頁面專用樣式 */
.table-container {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(30, 58, 111, 0.1);
    border: 2px solid rgba(212, 160, 23, 0.2);
}

.borrow-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    min-width: 1200px;
}

.borrow-table th,
.borrow-table td {
    padding: 14px;
    text-align: left;
    border-bottom: 1px solid #e8e8e8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 設定各欄位的寬度 */
.borrow-table th:nth-child(1), .borrow-table td:nth-child(1) { width: 8%; min-width: 80px; }
.borrow-table th:nth-child(2), .borrow-table td:nth-child(2) { width: 8%; min-width: 80px; }
.borrow-table th:nth-child(3), .borrow-table td:nth-child(3) { width: 8%; min-width: 70px; }
.borrow-table th:nth-child(4), .borrow-table td:nth-child(4) { width: 15%; min-width: 150px; }
.borrow-table th:nth-child(5), .borrow-table td:nth-child(5) { width: 10%; min-width: 80px; }
.borrow-table th:nth-child(6), .borrow-table td:nth-child(6) { width: 8%; min-width: 60px; }
.borrow-table th:nth-child(7), .borrow-table td:nth-child(7) { width: 12%; min-width: 100px; }
.borrow-table th:nth-child(8), .borrow-table td:nth-child(8) { width: 6%; min-width: 50px; }
.borrow-table th:nth-child(9), .borrow-table td:nth-child(9) { width: 15%; min-width: 120px; white-space: normal; }
.borrow-table th:nth-child(10), .borrow-table td:nth-child(10) { width: 10%; min-width: 90px; }

.borrow-table th {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--light-blue) 100%);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

.borrow-table tbody tr {
    transition: all 0.2s ease;
}

.borrow-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(212, 160, 23, 0.08) 0%, rgba(30, 58, 111, 0.05) 100%);
    transform: scale(1.01);
}

.borrow-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

.loading-container {
    text-align: center;
    padding: 50px;
}

.loading-container p {
    color: var(--primary-blue);
    font-weight: 600;
    margin-top: 15px;
}

.error-container {
    text-align: center;
    padding: 50px;
    color: var(--accent-red);
}

.error-container h3 {
    color: var(--accent-red);
    margin-bottom: 15px;
}

.refresh-btn,
.home-btn {
    margin-left: 10px;
    padding: 10px 20px;
    font-size: 14px;
}

.stats-info {
    background: linear-gradient(135deg, rgba(212, 160, 23, 0.12) 0%, rgba(30, 58, 111, 0.08) 100%);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    border-left: 4px solid var(--primary-gold);
    box-shadow: 0 2px 8px rgba(30, 58, 111, 0.08);
}

.stats-info .stat-item {
    margin: 8px 0;
    color: var(--text-dark);
    font-weight: 500;
}

.stats-info .stat-number {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--primary-blue);
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 借用清單頁面響應式設計 */
@media (max-width: 768px) {
    .borrow-table {
        min-width: 1000px;
    }
    
    .borrow-table th,
    .borrow-table td {
        padding: 10px;
        font-size: 13px;
    }
    
    .borrow-table th:nth-child(4), .borrow-table td:nth-child(4) { min-width: 120px; }
    .borrow-table th:nth-child(9), .borrow-table td:nth-child(9) { min-width: 100px; }
    
    .stats-info {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .borrow-table {
        min-width: 800px;
    }
    
    .borrow-table th,
    .borrow-table td {
        padding: 8px;
        font-size: 12px;
    }
}