:root {
    --primary-color: #3498db;
    --secondary-color: #2980b9;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    /* --mobile-padding: 10px; */
    --desktop-padding: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    padding: var(--mobile-padding);
    font-size: 14px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    grid-template-columns: 1fr;
    gap: 15px;
}

header {
    text-align: center;
    margin-bottom: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.header-content {
    flex: 1;
    min-width: auto;
}

h1 {
    font-size: 1.4rem;
    margin-bottom: 5px;
}

.description {
    font-size: 0.9rem;
    opacity: 0.9;
}

.panel {
    background: white;
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: var(--box-shadow);
    margin-bottom: 15px;
}

.panel-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.panel-title i {
    color: var(--primary-color);
    font-size: 1rem;
}

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

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #34495e;
    font-size: 0.9rem;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    min-height: 44px; /* 触摸友好的最小高度 */
}

.availability {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 44px; /* 触摸友好的最小高度 */
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

.checkbox-group label {
    margin: 0;
    font-size: 0.9rem;
}

button {
    padding: 12px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px; /* 触摸友好的最小高度 */
    touch-action: manipulation; /* 优化触摸响应 */
}

button:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

#generate-btn {
    background: var(--success-color);
    width: 100%;
    justify-content: center;
    margin-top: 12px;
    padding: 14px;
    font-size: 1rem;
}

#generate-btn:hover {
    background: #219653;
}

.people-list {
    margin-top: 12px;
    max-height: 250px;
    overflow-y: auto;
}

.person-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: move;
    border-left: 4px solid var(--primary-color);
    transition: all 0.2s;
    min-height: 60px; /* 触摸友好的最小高度 */
}

.person-item:hover {
    background: #e9ecef;
}

.person-info {
    flex-grow: 1;
}

.person-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.person-availability {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 3px;
}

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

.delete-btn {
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.delete-btn:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

.calendar-container {
    margin-top: 15px;
}

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

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

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.month-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.month-nav button {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
}

.month-nav .current-month {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
    margin: 0;
    min-width: 120px;
}

.weekday {
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
    padding: 8px 4px;
    background: #eef5ff;
    border-radius: 4px;
    font-size: 0.8rem;
}

.day {
    background: white;
    border-radius: 4px;
    padding: 8px;
    min-height: 80px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}

.day:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.day-number {
    font-weight: 600;
    margin-bottom: 4px;
    color: #2c3e50;
    font-size: 0.85rem;
}

.weekend {
    background: #fff5f5;
}

.weekend .day-number {
    color: var(--danger-color);
}

.duty-person {
    font-size: 0.75rem;
    padding: 3px 5px;
    background: #e8f4ff;
    border-radius: 3px;
    margin-top: auto;
    display: inline-block;
    word-break: break-word;
    line-height: 1.2;
}

.today .duty-person {
    font-size: 0.9rem;
    font-weight: 600;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.today {
    border: 2px solid var(--primary-color);
}

.empty-day {
    background: #f8f9fa;
    border: 1px dashed #ddd;
    cursor: default;
}

.empty-day:hover {
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.holiday {
    background: #fff8e1 !important;
    position: relative;
}

.holiday::after {
    content: "休";
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--warning-color);
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: bold;
}

.instructions {
    margin-top: 15px;
    padding: 10px;
    background: #fff8e1;
    border-radius: 6px;
    border-left: 4px solid var(--warning-color);
    font-size: 0.85rem;
}

.instructions h3 {
    margin-bottom: 6px;
    color: #d35400;
    font-size: 0.9rem;
}

.instructions ul {
    padding-left: 18px;
}

.instructions li {
    margin-bottom: 4px;
}

.history-panel {
    margin-top: 15px;
}

.duty-instructions {
    margin-bottom: 15px;
    padding: 12px 15px;
    background: #e8f4ff;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
    font-size: 0.85rem;
}

.duty-instructions h4 {
    margin-bottom: 8px;
    color: var(--primary-color);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.duty-instructions h4 i {
    font-size: 0.8rem;
}

.duty-instructions ul {
    padding-left: 18px;
    margin: 0;
}

.duty-instructions li {
    margin-bottom: 4px;
    line-height: 1.4;
}

.duty-instructions strong {
    color: var(--primary-color);
    font-weight: 600;
}

.history-list {
    max-height: 180px;
    overflow-y: auto;
    margin-top: 8px;
}

.history-item {
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 44px;
}

.history-date {
    font-weight: 600;
    font-size: 0.85rem;
}

.history-action {
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.history-action:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.modal-title {
    margin-bottom: 15px;
    text-align: center;
    color: #2c3e50;
    font-size: 1.1rem;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.modal-buttons button {
    flex: 1;
}

.cancel-btn {
    background: #95a5a6;
}

.cancel-btn:hover {
    background: #7f8c8d;
}

.admin-panel {
    display: none;
}

.view-panel {
    display: block;
}

.password-form {
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.admin-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.admin-actions button {
    flex: 1;
    min-width: 120px;
}

.exit-admin-btn {
    background: var(--danger-color);
}

.exit-admin-btn:hover {
    background: #c0392b;
}

.holiday-calendar {
    margin-top: 15px;
}

.holiday-note {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 8px;
    text-align: center;
}

.version-info {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    text-align: center;
}

.version {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.copyright {
    font-size: 0.8rem;
    color: #7f8c8d;
    opacity: 0.8;
}

.person-selector-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    background: #f8f9fa;
}

.person-selector-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 5px;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.person-selector-item:hover {
    background: #e8f4ff;
    border-color: var(--primary-color);
}

.person-selector-item.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.person-selector-item input[type="radio"] {
    margin-right: 8px;
}

.person-selector-item .person-name {
    font-weight: 600;
}

.person-selector-item .person-restrictions {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-left: auto;
}

/* 移动端优先的响应式布局 */
@media (min-width: 480px) {
    body {
        padding: 15px;
        font-size: 15px;
    }
    
    .container {
        gap: 20px;
    }
    
    .panel {
        padding: 20px;
    }
    
    .calendar {
        gap: 6px;
    }
    
    .weekdays {
        gap: 6px;
    }
    
    .day {
        min-height: 90px;
        padding: 10px;
    }
    
    .weekday {
        font-size: 0.85rem;
        padding: 8px 5px;
    }
    
    .duty-person {
        font-size: 0.8rem;
        padding: 4px 6px;
    }
    
    .today .duty-person {
        font-size: 0.95rem;
    }
}

@media (min-width: 768px) {
    body {
        padding: var(--desktop-padding);
        font-size: 18px;
    }
    
    .container {
        grid-template-columns: 1fr 1fr;
        gap: 25px;
    }
    
    header {
        grid-column: 1 / -1;
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }
    
    .header-content {
        min-width: 300px;
    }
    
    h1 {
        font-size: 2.2rem;
    }
    
    .description {
        font-size: 1.2rem;
    }
    
    .view-panel {
        grid-column: 1 / -1;
    }
    
    .admin-panel {
        grid-column: 1 / -1;
    }
    
    .calendar {
        gap: 8px;
    }
    
    .weekdays {
        gap: 8px;
    }
    
    .day {
        min-height: 100px;
        padding: 10px;
    }
    
    .day-number {
        font-size: 1.1rem;
    }
    
    .weekday {
        font-size: 1.1rem;
        padding: 10px 6px;
    }
    
    .duty-person {
        font-size: 0.95rem;
        padding: 5px 7px;
    }
    
    .today .duty-person {
        font-size: 1.2rem;
    }
    
    .panel-title {
        font-size: 1.4rem;
    }
    
    .current-month {
        font-size: 1.4rem;
    }
    
    .month-nav .current-month {
        font-size: 1.4rem;
    }
    
    button {
        font-size: 1.1rem;
        padding: 14px 18px;
    }
    
    input[type="text"], input[type="password"] {
        font-size: 1.1rem;
        padding: 14px 16px;
    }
    
    label {
        font-size: 1rem;
    }
    
    .person-name {
        font-size: 1.1rem;
    }
    
    .person-availability {
        font-size: 0.9rem;
    }
    
    .history-date {
        font-size: 1rem;
    }
    
    .history-action {
        font-size: 1rem;
    }
    
    .instructions {
        font-size: 1rem;
    }
    
    .instructions h3 {
        font-size: 1.1rem;
    }
    
    .duty-instructions {
        font-size: 1rem;
    }
    
    .duty-instructions h4 {
        font-size: 1.1rem;
    }
    
    .version {
        font-size: 1rem;
    }
    
    .copyright {
        font-size: 0.9rem;
    }
}

@media (min-width: 992px) {
    .container {
        grid-template-columns: 1fr 2fr;
    }
    
    .view-panel {
        grid-column: 2 / 3;
        grid-row: 2 / 3;
    }
    
    .admin-panel {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
    }
    
    body {
        font-size: 19px;
    }
    
    h1 {
        font-size: 2.4rem;
    }
    
    .description {
        font-size: 1.3rem;
    }
    
    .panel-title {
        font-size: 1.5rem;
    }
    
    .day-number {
        font-size: 1.2rem;
    }
    
    .weekday {
        font-size: 1.2rem;
    }
    
    .duty-person {
        font-size: 1rem;
    }
    
    .today .duty-person {
        font-size: 1.3rem;
    }
    
    button {
        font-size: 1.15rem;
    }
    
    input[type="text"], input[type="password"] {
        font-size: 1.15rem;
    }
}

@media (max-width: 767px) {
    .calendar {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .weekdays {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .weekday {
        font-size: 0.7rem;
        padding: 4px 2px;
    }
    
    .day {
        min-height: 80px;
        padding: 6px;
    }
    
    .day-number {
        font-size: 0.8rem;
    }
    
    .duty-person {
        font-size: 0.7rem;
        padding: 2px 4px;
    }
    
    .today .duty-person {
        font-size: 0.85rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .description {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .calendar {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .weekdays {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .weekday {
        font-size: 0.6rem;
        padding: 3px 1px;
    }
    
    .day {
        min-height: 70px;
        padding: 4px;
    }
    
    .day-number {
        font-size: 0.75rem;
    }
    
    .duty-person {
        font-size: 0.65rem;
        padding: 1px 3px;
    }
    
    .today .duty-person {
        font-size: 0.8rem;
    }
    
    .month-nav {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }
    
    .month-nav .current-month {
        font-size: 0.9rem;
        min-width: 90px;
    }
    
    header {
        flex-direction: column;
        text-align: center;
    }
    
    .header-content {
        min-width: auto;
    }
}

/* 超小屏幕优化 */
@media (max-width: 360px) {
    body {
        padding: 8px;
        font-size: 13px;
    }
    
    .panel {
        padding: 12px;
    }
    
    .calendar {
        gap: 1px;
    }
    
    .weekdays {
        gap: 1px;
    }
    
    .day {
        min-height: 60px;
        padding: 3px;
    }
    
    .weekday {
        font-size: 0.55rem;
        padding: 2px 1px;
    }
    
    .day-number {
        font-size: 0.7rem;
    }
    
    .duty-person {
        font-size: 0.6rem;
        padding: 1px 2px;
    }
    
    .today .duty-person {
        font-size: 0.75rem;
    }
    
    h1 {
        font-size: 1.2rem;
    }
    
    .description {
        font-size: 0.8rem;
    }
    
    .month-nav .current-month {
        font-size: 0.8rem;
        min-width: 80px;
    }
}

/* 横屏模式优化 */
@media (max-height: 500px) and (orientation: landscape) {
    .people-list {
        max-height: 150px;
    }
    
    .history-list {
        max-height: 120px;
    }
    
    .day {
        min-height: 60px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    button:hover {
        transform: none;
    }
    
    .day:hover {
        transform: none;
    }
    
    .person-item:hover {
        background: #f8f9fa;
    }
    
    .delete-btn:hover {
        background-color: transparent;
    }
    
    .history-action:hover {
        background-color: transparent;
    }
}
