/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --success: #16a34a;
    --warning: #ca8a04;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.view {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Header */
.header {
    background: white;
    padding: 16px 20px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

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

/* Typography */
h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 12px;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.subtitle {
    color: var(--gray-500);
    margin-bottom: 32px;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:hover {
    transform: translateY(-1px);
}

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

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

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

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

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

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

.btn-small {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-icon {
    padding: 6px;
    background: transparent;
    color: var(--gray-500);
}

.btn-icon:hover {
    color: var(--gray-700);
    background: var(--gray-100);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-row input {
    flex: 1;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input {
    width: auto !important;
}

/* Divider */
.divider {
    text-align: center;
    color: var(--gray-400);
    margin: 24px 0;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 20px);
    height: 1px;
    background: var(--gray-200);
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

/* Member Selection */
.member-select-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.member-select-card label {
    font-weight: 500;
    white-space: nowrap;
}

.member-select-card select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
}

/* Leaderboard */
.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.leaderboard-rank {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-200);
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.875rem;
    margin-right: 12px;
}

.leaderboard-item:nth-child(1) .leaderboard-rank {
    background: #fef08a;
    color: #854d0e;
}

.leaderboard-item:nth-child(2) .leaderboard-rank {
    background: #e5e7eb;
    color: #374151;
}

.leaderboard-item:nth-child(3) .leaderboard-rank {
    background: #fed7aa;
    color: #9a3412;
}

.leaderboard-name {
    flex: 1;
    font-weight: 500;
}

.leaderboard-points {
    font-weight: 600;
    color: var(--primary);
}

/* Tasks List */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-item {
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.task-item.claimed {
    border-left-color: var(--warning);
}

.task-item.completed {
    border-left-color: var(--success);
    opacity: 0.7;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.task-name {
    font-weight: 600;
}

.task-points {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.task-description {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.task-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--gray-500);
}

.task-due {
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-due.overdue {
    color: var(--danger);
    font-weight: 500;
}

/* Task Sections */
.task-section {
    margin-bottom: 20px;
}

.task-section:last-child {
    margin-bottom: 0;
}

.task-section-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 8px;
    padding-left: 4px;
}

.task-section-overdue .task-section-header {
    color: var(--danger);
}

.task-item.overdue {
    border-left-color: var(--danger);
    background: #fef2f2;
}

.task-claimed-by {
    font-style: italic;
}

.task-claimed-by.task-can-claim {
    color: var(--success);
    font-style: normal;
}

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

/* History */
.history-card summary {
    cursor: pointer;
    list-style: none;
}

.history-card summary::-webkit-details-marker {
    display: none;
}

.history-card summary h2 {
    display: inline;
}

.history-card summary h2::after {
    content: ' +';
    color: var(--gray-400);
}

.history-card[open] summary h2::after {
    content: ' -';
}

.history-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.history-action {
    font-weight: 500;
}

.history-points {
    color: var(--success);
    font-weight: 600;
}

.history-points.negative {
    color: var(--danger);
}

.history-details {
    color: var(--gray-500);
}

.history-time {
    color: var(--gray-400);
    font-size: 0.75rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--gray-200);
    padding: 4px;
    border-radius: var(--radius);
}

.tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tab:hover {
    background: var(--gray-100);
}

.tab.active {
    background: white;
    box-shadow: var(--shadow);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Admin List */
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.admin-list-item-info {
    flex: 1;
}

.admin-list-item-name {
    font-weight: 500;
}

.admin-list-item-meta {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.admin-list-item-actions {
    display: flex;
    gap: 4px;
}

/* Code Display */
.code-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--gray-800);
    border-radius: var(--radius);
    margin-top: 12px;
}

.code-display span {
    flex: 1;
    font-family: monospace;
    font-size: 1.25rem;
    color: white;
    letter-spacing: 2px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.modal-content h2 {
    margin-bottom: 16px;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--gray-400);
    padding: 24px;
}

/* Error */
.error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 8px;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

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

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

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

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .card {
        padding: 16px;
    }

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

    .form-row .form-group {
        margin-bottom: 0;
    }

    .header {
        padding: 12px 16px;
    }

    .header h1 {
        font-size: 1rem;
    }

    .btn-small {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}

.task-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: #e0e7ff;
    color: #4f46e5;
    font-weight: 500;
    margin-left: 6px;
    vertical-align: middle;
}
