/* 基本重置與深色背景設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    min-height: 100vh;
    background-color: #0b1121; /* 圖片中的深藍背景色 */
    color: #e2e8f0;
}

/* 左側邊欄 */
.sidebar {
    width: 260px;
    background-color: #0f172a;
    border-right: 1px solid #1e293b;
    padding: 20px 0;
}

.logo {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    padding-bottom: 20px;
    border-bottom: 1px solid #1e293b;
}

.sidebar nav ul {
    list-style: none;
    margin-top: 20px;
}

.sidebar nav ul li a {
    display: block;
    padding: 15px 25px;
    color: #94a3b8;
    text-decoration: none;
    transition: 0.3s;
}

.sidebar nav ul li.active a, .sidebar nav ul li a:hover {
    background-color: #1e40af; /* 選中的藍色 */
    color: white;
}

/* 主內容區 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
}

/* 數據卡片 */
.summary-cards {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    flex: 1;
    background-color: #111827;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #1e293b;
}

.card .number {
    font-size: 28px;
    font-weight: bold;
    margin: 10px 0;
}

/* 圖表區 */
.charts-section {
    display: flex;
    gap: 20px;
}

.chart-container {
    flex: 1;
    background-color: #111827;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #1e293b;
}

.view-section {
    display: none;
}

.view-section.active-view {
    display: block;
}

.chart-fallback {
    align-items: center;
    color: #f59e0b;
    display: flex;
    justify-content: center;
    min-height: 300px;
    text-align: center;
}

.table-section {
    overflow-x: auto;
}

tbody td {
    padding: 12px;
}

.inventory-row {
    border-bottom: 1px solid #1e293b;
    color: #e2e8f0;
    text-align: left;
}

.item-name,
.stock-ok,
.stock-warning {
    font-weight: bold;
}

.muted {
    color: #94a3b8;
}

.stock-warning {
    color: #ef4444;
}

.status-badge {
    border-radius: 4px;
    display: inline-block;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 8px;
}

.table-message {
    color: #94a3b8;
    padding: 20px;
    text-align: center;
}

.table-message.error {
    color: #ef4444;
}

.room-shortage-group {
    margin-bottom: 20px;
}

.room-shortage-group h4 {
    color: #3b82f6;
    margin-bottom: 10px;
}

.shortage-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.shortage-tags span {
    background: #1e293b;
    border-radius: 6px;
    color: #f59e0b;
    font-size: 13px;
    padding: 6px 10px;
}

.empty-state {
    color: #10b981;
    padding: 20px;
    text-align: center;
}

.management-panel {
    background-color: #111827;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 20px;
}

.section-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-header h3 {
    color: #e2e8f0;
    font-size: 18px;
    margin-bottom: 6px;
}

.section-header p {
    color: #94a3b8;
    font-size: 13px;
}

.management-toolbar {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(240px, 1fr) 180px 180px;
    margin-bottom: 18px;
}

.management-toolbar input,
.management-toolbar select {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 14px;
    min-height: 40px;
    padding: 0 12px;
}

.management-toolbar input::placeholder {
    color: #64748b;
}

.materials-table-wrap {
    overflow-x: auto;
}

.materials-table {
    border-collapse: collapse;
    font-size: 14px;
    min-width: 980px;
    text-align: left;
    width: 100%;
}

.materials-table th {
    border-bottom: 1px solid #1e293b;
    color: #94a3b8;
    font-weight: 600;
    padding: 12px;
}

.transaction-layout {
    align-items: start;
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 1fr) 320px;
}

.transaction-panel,
.transaction-summary {
    background-color: #111827;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 20px;
}

.transaction-form {
    display: grid;
    gap: 16px;
}

.transaction-form label {
    display: grid;
    gap: 8px;
}

.transaction-form span {
    color: #94a3b8;
    font-size: 13px;
}

.transaction-form input,
.transaction-form select,
.transaction-form textarea {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 14px;
    min-height: 42px;
    padding: 0 12px;
}

.transaction-form textarea {
    min-height: 96px;
    padding: 12px;
    resize: vertical;
}

.form-grid {
    display: grid;
    gap: 12px;
}

.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-actions {
    display: flex;
    gap: 12px;
}

.primary-button,
.secondary-button {
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    min-height: 40px;
    padding: 0 16px;
}

.primary-button {
    background: #2563eb;
    border: 1px solid #2563eb;
    color: #ffffff;
}

.secondary-button {
    background: transparent;
    border: 1px solid #334155;
    color: #cbd5e1;
}

.form-status {
    border-radius: 6px;
    color: #94a3b8;
    font-size: 14px;
    min-height: 20px;
}

.form-status.success {
    color: #10b981;
}

.form-status.error {
    color: #ef4444;
}

.transaction-summary h3 {
    color: #e2e8f0;
    font-size: 16px;
    margin-bottom: 16px;
}

.transaction-summary dl {
    display: grid;
    gap: 14px;
}

.transaction-summary div {
    border-bottom: 1px solid #1e293b;
    padding-bottom: 12px;
}

.transaction-summary dt {
    color: #94a3b8;
    font-size: 12px;
    margin-bottom: 5px;
}

.transaction-summary dd {
    color: #e2e8f0;
    font-size: 15px;
    font-weight: 600;
}

@media (max-width: 900px) {
    body {
        display: block;
    }

    .sidebar {
        border-bottom: 1px solid #1e293b;
        border-right: 0;
        width: 100%;
    }

    .sidebar nav ul {
        display: flex;
        gap: 8px;
        margin-top: 16px;
        overflow-x: auto;
        padding: 0 16px 4px;
    }

    .sidebar nav ul li {
        flex: 0 0 auto;
    }

    .sidebar nav ul li a {
        border-radius: 6px;
        padding: 10px 14px;
        white-space: nowrap;
    }

    .main-content {
        padding: 16px;
    }

    .summary-cards,
    .charts-section {
        flex-direction: column;
    }

    .top-nav {
        gap: 12px;
        margin-bottom: 20px;
    }

    .management-toolbar {
        grid-template-columns: 1fr;
    }

    .transaction-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .logo {
        font-size: 20px;
    }

    .top-nav {
        align-items: flex-start;
        flex-direction: column;
    }

    .card {
        padding: 16px;
    }

    .chart-container {
        padding: 16px;
    }

    .two-columns {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }
}
