/* ═══════════════════════════════════════════════════
   会议室预约系统 - 样式表
   ═══════════════════════════════════════════════════ */

/* ─── Reset ─── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #4338ca;
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --booked-bg: #dbeafe;
    --booked-dot: #2563eb;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --radius: 14px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ═══ 日历页面 ═══ */

.app-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 顶部栏 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.room-icon {
    font-size: 28px;
}

.room-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.room-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.qr-link-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: var(--primary-50);
    color: var(--primary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.qr-link-btn:hover {
    background: var(--primary-100);
}

/* 日历区域 */
.calendar-section {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    flex: 1;
}

.calendar-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-bottom: 20px;
}

.month-nav-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--primary-50);
    color: var(--primary);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.month-nav-btn:hover {
    background: var(--primary-100);
    transform: scale(1.05);
}

.month-title {
    font-size: 20px;
    font-weight: 700;
    min-width: 160px;
    text-align: center;
}

/* 日历网格 */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.weekday-header {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 0;
}

.weekday-header.sunday {
    color: var(--error);
}

/* 日期单元格 */
.day-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border: 2px solid transparent;
    user-select: none;
}

.day-cell.empty {
    cursor: default;
    pointer-events: none;
}

.day-cell .day-number {
    font-size: 16px;
    font-weight: 500;
}

.day-cell .day-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    margin-top: 3px;
    background: transparent;
}

/* 今天的日期 */
.day-cell.today {
    border-color: var(--primary);
    font-weight: 700;
}

.day-cell.today .day-number {
    color: var(--primary);
}

/* 有预约的日期（优先级高于 available，放在后面） */
.day-cell.has-booking {
    background: var(--booked-bg);
}

.day-cell.has-booking .day-dot {
    background: var(--booked-dot);
}

/* 空闲日期 */
.day-cell.available:not(.today):not(.has-booking) {
    background: var(--surface);
}

.day-cell.available:not(.has-booking):hover {
    background: var(--primary-50);
}

/* 过去的日期 */
.day-cell.past {
    color: var(--text-secondary);
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* 周日 */
.day-cell.sunday:not(.past) .day-number {
    color: var(--error);
}

/* 图例 */
.legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
}

.legend-today {
    border: 2px solid var(--primary);
    background: transparent;
}

.legend-booked {
    background: var(--booked-bg);
    border: 1px solid #93c5fd;
}

.legend-empty {
    background: var(--surface);
    border: 1px solid var(--border);
}

/* 底部提示 */
.bottom-hint {
    text-align: center;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ═══ 预约弹窗 ═══ */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

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

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

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    z-index: 1;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--border-light);
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--error-bg);
    color: var(--error);
}

.modal-body {
    padding: 20px 24px;
}

/* 时段选择 */
.slots-section {
    margin-bottom: 20px;
}

.period-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    margin-top: 12px;
}

.period-label:first-child {
    margin-top: 0;
}

.slots-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.slot-btn {
    padding: 12px 4px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    position: relative;
}

.slot-btn .slot-time {
    display: block;
    font-weight: 600;
    font-size: 13px;
}

.slot-btn .slot-status {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.slot-btn.available:hover {
    border-color: var(--primary-light);
    background: var(--primary-50);
}

.slot-btn.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.slot-btn.selected .slot-status {
    color: rgba(255,255,255,0.8);
}

.slot-btn.booked {
    background: var(--border-light);
    border-color: var(--border-light);
    cursor: not-allowed;
    opacity: 0.6;
}

.slot-btn.booked .slot-status {
    color: var(--error);
}

/* 表单 */
.form-section {
    border-top: 1px solid var(--border-light);
    padding-top: 20px;
}

.form-group {
    margin-bottom: 14px;
}

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

.form-row .form-group {
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.required {
    color: var(--error);
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
    color: var(--text);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group input::placeholder {
    color: #cbd5e1;
}

/* 消息区域 */
.message-area {
    min-height: 0;
    margin-top: 8px;
}

.message-area .msg {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: none;
}

.message-area .msg.error {
    display: block;
    background: var(--error-bg);
    color: var(--error);
}

.message-area .msg.success {
    display: block;
    background: var(--success-bg);
    color: var(--success);
}

/* 弹窗底部按钮 */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-radius: 0 0 var(--radius) var(--radius);
}

.btn {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-cancel {
    background: var(--border-light);
    color: var(--text-secondary);
}

.btn-cancel:hover {
    background: #e2e8f0;
}

.btn-submit {
    background: var(--primary);
    color: white;
}

.btn-submit:hover {
    background: var(--primary-dark);
}

.btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 12px 28px;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: var(--shadow);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

/* ═══ 二维码页面 ═══ */

.qr-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--bg);
}

.qr-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 48px;
    text-align: center;
    max-width: 420px;
}

.qr-room-name {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.qr-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.qr-image-box {
    display: inline-block;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.qr-image {
    width: 240px;
    height: 240px;
}

.qr-url-box {
    background: var(--bg);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.qr-url-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.qr-url {
    font-size: 14px;
    font-family: monospace;
    color: var(--primary);
    word-break: break-all;
}

.qr-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.qr-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-print {
    background: var(--primary);
    color: white;
}

.btn-print:hover {
    background: var(--primary-dark);
}

.btn-back {
    background: var(--border-light);
    color: var(--text-secondary);
}

/* ═══ 管理页面 ═══ */

.admin-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px;
}

.admin-header {
    text-align: center;
    margin-bottom: 32px;
}

.admin-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.admin-header p {
    color: var(--text-secondary);
    font-size: 14px;
    font-family: monospace;
}

.admin-section {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.admin-section h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

/* 会议室卡片 */
.room-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.room-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: box-shadow 0.2s;
}

.room-card:hover {
    box-shadow: var(--shadow-sm);
}

.room-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.room-card-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.room-card-id {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
}

.room-card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.room-card-actions {
    display: flex;
    gap: 8px;
}

/* 按钮 */
.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-outline {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--bg);
}

.btn-danger {
    background: var(--error-bg);
    color: var(--error);
    padding: 6px 14px;
    font-size: 13px;
}

.btn-danger:hover {
    background: var(--error);
    color: white;
}

/* 添加会议室表单 */
.add-room-form {
    border-top: 1px solid var(--border-light);
    padding-top: 20px;
}

.add-room-form h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.admin-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
}

.admin-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* 预约表格 */
.table-wrapper {
    overflow-x: auto;
}

.booking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.booking-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

.booking-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.booking-table tbody tr:hover {
    background: var(--bg);
}

.empty-hint {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px;
}

/* ═══ 响应式 ═══ */

@media (max-width: 640px) {
    .app-container {
        padding: 8px;
    }

    .top-bar {
        padding: 14px 16px;
    }

    .room-name {
        font-size: 17px;
    }

    .calendar-section {
        padding: 16px 12px;
    }

    .calendar-header {
        gap: 16px;
    }

    .month-title {
        font-size: 18px;
        min-width: 120px;
    }

    .day-cell .day-number {
        font-size: 14px;
    }

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

    .modal-content {
        max-width: 100%;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

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

    .legend {
        gap: 16px;
    }

    .qr-card {
        padding: 28px 24px;
    }

    .qr-image {
        width: 200px;
        height: 200px;
    }

    .room-cards {
        grid-template-columns: 1fr;
    }
}

/* 打印样式 */
@media print {
    body { background: white; }
    .qr-actions, .qr-hint { display: none; }
    .qr-card { box-shadow: none; border: 2px solid #333; }
}
