:root {
    --primary-color: #007AFF;
    --secondary-color: #ff9900;
    --danger-color: #FF3B30;
    --success-color: #34C759;
    --background-color: #F2F2F7;
    --card-background: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --border-radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--card-background);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    animation: scaleIn 0.5s ease-out;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    animation: slideInFromTop 0.5s ease-out;
}

h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.buttons {
    display: flex;
    justify-content: center;
    margin-top: 32px;
}

.button-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
}

.button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    color: white;
    font-weight: 500;
    font-size: 16px;
    transition: var(--transition-bounce);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.button::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10);
    opacity: 0;
    transition: transform .5s, opacity 1s;
}

.button:active::after {
    transform: scale(0);
    opacity: .3;
    transition: 0s;
}

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

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

.button.good {
    background-color: var(--success-color);
}

.button.bad {
    background-color: var(--danger-color);
}

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


.button.default {
    background-color: var(--primary-color);
}

.button.secondary {
    background-color: var(--secondary-color);
    color: white;
}

.form-group {
    margin-bottom: 20px;
    animation: slideInFromLeft 0.5s ease-out;
    animation-fill-mode: both;
}

.form-group:nth-child(1) {
    animation-delay: 0.1s;
}

.form-group:nth-child(2) {
    animation-delay: 0.2s;
}

.form-group:nth-child(3) {
    animation-delay: 0.3s;
}

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

input,
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 16px;
    transition: var(--transition-normal);
    background-color: #FFFFFF;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    transform: translateY(-1px);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238E8E93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

select:disabled {
    background-color: #F2F2F7;
    color: var(--text-secondary);
    cursor: not-allowed;
}

textarea {
    height: 120px;
    resize: vertical;
}

.user-info {
    background-color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary-color);
    flex-wrap: wrap;
    animation: slideInFromLeft 0.5s ease-out;
    transition: var(--transition-normal);
}

.user-info .button,
.button.small {
    background-color: var(--text-secondary);
    color: white;
}

.button.secondary:hover,
.user-info .button:hover,
.button.small:hover {
    background-color: #7a7a81;
}

.error-message {
    background-color: rgba(255, 59, 48, 0.1);
    color: var(--danger-color);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    animation: slideInFromTop 0.5s ease-out;
}

.success-message {
    background-color: rgba(52, 199, 89, 0.1);
    color: var(--success-color);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    animation: slideInFromTop 0.5s ease-out;
}

.login-form {
    max-width: 400px;
    margin: 0 auto;
}

.stats-form {
    background-color: var(--background-color);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 24px;
}

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

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

.table-container {
    overflow-x: auto;
    margin-top: 24px;
    -webkit-overflow-scrolling: touch;
    animation: scaleIn 0.5s ease-out;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    border-radius: var(--border-radius);
    overflow: hidden;
}

th,
td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

th {
    background-color: var(--background-color);
    font-weight: 500;
    color: var(--text-secondary);
}

.button.small {
    padding: 6px 12px;
    min-width: auto;
    font-size: 14px;
}

.stats-title {
    margin-top: 32px;
    font-size: 18px;
    color: var(--text-secondary);
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-normal);
}

.badge.good {
    background-color: rgba(52, 199, 89, 0.1);
    color: var(--success-color);
}

.badge.bad {
    background-color: rgba(255, 59, 48, 0.1);
    color: var(--danger-color);
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Dropdown Styles */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    width: 100%;
}

.dropdown-toggle::after {
    content: '';
    display: inline-block;
    margin-left: 8px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid white;
    transition: transform 0.3s ease;
    vertical-align: middle;
}

.dropdown:hover .dropdown-toggle::after {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    /* Position below button with gap */
    left: 0;
    width: 100%;
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    padding: 8px 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    /* Animation setup */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transform-origin: top center;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s linear;
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-item {
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-primary);
    display: block;
    font-weight: 500;
    white-space: nowrap;

    /* Staggered animation setup */
    opacity: 0;
    transform: translateX(-15px);
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.dropdown:hover .dropdown-menu .dropdown-item {
    opacity: 1;
    transform: translateX(0);
}

/* Staggered animation delay */
.dropdown:hover .dropdown-menu .dropdown-item:nth-child(1) {
    transition-delay: 0.05s;
}

.dropdown:hover .dropdown-menu .dropdown-item:nth-child(2) {
    transition-delay: 0.1s;
}

.dropdown:hover .dropdown-menu .dropdown-item:nth-child(3) {
    transition-delay: 0.15s;
}

.dropdown:hover .dropdown-menu .dropdown-item:nth-child(4) {
    transition-delay: 0.2s;
}

.dropdown-item:hover {
    background-color: var(--background-color);
}

.dropdown-item.good {
    color: var(--success-color);
}

.dropdown-item.bad {
    color: var(--danger-color);
}

.dropdown-item.primary {
    color: var(--primary-color);
}

.dropdown-item.good:hover {
    background-color: rgba(52, 199, 89, 0.1);
}

.dropdown-item.bad:hover {
    background-color: rgba(255, 59, 48, 0.1);
}

.dropdown-item.primary:hover {
    background-color: rgba(0, 122, 255, 0.1);
}

/* 响应式设计增强 */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        padding: 16px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .button-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
        padding: 8px 12px;
    }

    .button {
        width: 100%;
        justify-content: center;
    }

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

    .form-row .form-group {
        width: 100%;
    }

    .table-container {
        margin: 16px -16px;
        width: calc(100% + 32px);
    }

    table {
        border-radius: 0;
    }

    th,
    td {
        padding: 8px 12px;
        font-size: 14px;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .actions .button {
        width: 100%;
    }

    .filter-controls {
        margin: 16px -16px;
        padding: 16px;
        border-radius: 0;
    }

    .button-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .button-group .button {
        width: 100%;
    }

    .date-range {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .date-range .button {
        width: 100%;
    }

    .button:hover {
        transform: none;
    }

    .checkbox-item:hover {
        transform: none;
    }

    tr:hover {
        transform: none;
    }

    /* 为移动端优化动画性能 */
    * {
        animation-duration: 0.3s;
    }
}

/* For smaller mobile screens */
@media (max-width: 480px) {
    .button-container {
        grid-template-columns: 1fr;
    }
}

/* 针对特小屏幕的优化 */
@media (max-width: 360px) {
    .container {
        padding: 12px;
    }

    h1 {
        font-size: 20px;
    }

    .button {
        font-size: 14px;
        padding: 10px 16px;
    }

    .user-info {
        font-size: 14px;
    }
}


.student-list::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 20px;
    border: 3px solid transparent;
    background-clip: content-box;
}

.student-list::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

.counter-item {
    background: white;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease-out forwards;
    opacity: 0;
    border: 1px solid transparent;
    transition: var(--transition);
}

.counter-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

@keyframes slideIn {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.student-name {
    font-weight: 600;
    color: var(--text-main);
}

.counter-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.counter-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    transition: var(--transition);
}

.counter-btn:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.counter-controls input {
    width: 48px;
    text-align: center;
    padding: 0.25rem;
    border: none;
    background: transparent;
    font-weight: 700;
    font-size: 1.1rem;
}

/* Loading */
.loading-container {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.loading {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(37, 99, 235, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error Message */
.error-message {
    background-color: #fef2f2;
    color: #dc2626;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid #fecaca;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

/* Utility Classes */
.full-width {
    width: 100%;
}

.icon-sm {
    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.ml-2 {
    margin-left: 0.5rem;
}

.text-center {
    text-align: center;
}

.flex {
    display: flex;
}

.items-end {
    align-items: flex-end;
}

.gap-2 {
    gap: 0.5rem;
}

.filter-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.date-range {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        margin: 0;
        padding: 1.5rem;
        width: 100%;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .user-info {
        width: 100%;
        justify-content: center;
    }

    h1 {
        font-size: 1.75rem;
    }

    .button-container {
        flex-direction: column;
    }

    .dropdown,
    .dropdown-toggle {
        width: 100%;
    }

    .dropdown-menu {
        position: static;
        width: 100%;
        box-shadow: none;
        border: none;
        transform: none;
        display: none;
        background-color: var(--bg-input);
    }

    .dropdown.active .dropdown-menu {
        display: block;
    }

    .filter-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .button-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .button-group .button {
        width: 100%;
    }
}