:root {
    --primary: #2c5530;
    --primary-light: #3d7a43;
    --primary-dark: #1a3a1d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --white: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --border-radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --transition: 0.2s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-100);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* Header */
#header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--primary);
    color: var(--white);
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    max-width: 600px;
    margin: 0 auto;
}

#page-title {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
    margin: 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.icon-btn {
    background: none;
    border: none;
    color: inherit;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition);
}

.icon-btn:hover, .icon-btn:focus {
    background: rgba(255,255,255,0.1);
}

.icon-btn svg {
    width: 24px;
    height: 24px;
}

.hidden {
    display: none !important;
}

/* Sync Indicator */
.sync-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--warning);
    color: var(--gray-900);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.sync-indicator svg {
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
}

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

/* Menu */
.menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
}

.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
}

.menu-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 80%;
    height: 100%;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.menu-header {
    background: var(--primary);
    color: var(--white);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-header #menu-user {
    font-size: 1.125rem;
    font-weight: 600;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(255,255,255,0.2);
    width: fit-content;
}

.menu-items {
    list-style: none;
    padding: 8px 0;
}

.menu-items li a {
    display: block;
    padding: 16px;
    color: var(--gray-800);
    text-decoration: none;
    transition: background var(--transition);
}

.menu-items li a:hover {
    background: var(--gray-100);
}

/* Main Content */
#main {
    flex: 1;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 16px;
}

.page {
    animation: fadeIn 0.2s ease;
}

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

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
}

.login-container {
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-logo {
    margin-bottom: 24px;
}

.login-logo img {
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.login-container h2 {
    margin-bottom: 24px;
    color: var(--primary);
}

/* Forms */
.form {
    text-align: left;
}

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

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

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

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

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

.form-container h2 {
    margin-bottom: 24px;
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

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

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

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

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

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

.btn-danger:hover {
    background: #c82333;
}

.btn-warning {
    background: var(--warning);
    color: var(--gray-900);
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-block {
    width: 100%;
}

/* Answer Buttons */
.btn-answer {
    flex: 1;
    padding: 24px;
    font-size: 1.5rem;
    min-height: 80px;
    border-radius: 16px;
}

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

.btn-yes:hover {
    background: #218838;
}

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

.btn-no:hover {
    background: #c82333;
}

/* Time and Points Inputs */
.time-input,
.points-input {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.time-input label,
.points-input label {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--dark);
}

.time-fields {
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-field {
    width: 70px;
    height: 60px;
    font-size: 1.5rem;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--white);
}

.time-field:focus {
    border-color: var(--primary);
    outline: none;
}

.time-separator {
    font-size: 2rem;
    font-weight: bold;
    color: var(--dark);
}

.points-field {
    width: 120px;
    height: 60px;
    font-size: 1.5rem;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--white);
}

.points-field:focus {
    border-color: var(--primary);
    outline: none;
}

.submit-action {
    margin-top: 16px;
}

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

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    min-height: 64px;
}

.list-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.list-item:active {
    transform: translateY(0);
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-weight: 600;
    color: var(--gray-900);
}

.list-item-subtitle {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.list-item-badge {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--gray-200);
    color: var(--gray-700);
}

.list-item-badge.completed {
    background: var(--success);
    color: var(--white);
}

.list-item-badge.in-progress {
    background: var(--warning);
    color: var(--gray-900);
}

/* Progress */
.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

/* Question Page */
.question-page {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 120px);
}

.question-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.question-progress .progress-bar {
    flex: 1;
}

.progress-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
}

.question-area {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.question-text {
    flex: 1;
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--gray-900);
    text-align: center;
    padding: 24px 0;
}

.question-actions {
    display: flex;
    gap: 16px;
    padding: 16px 0;
}

/* Complete Page */
.complete-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
    text-align: center;
}

.complete-icon {
    width: 120px;
    height: 120px;
    background: var(--success);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    margin-bottom: 24px;
}

.complete-page h2 {
    color: var(--success);
    margin-bottom: 8px;
}

.complete-page p {
    color: var(--gray-600);
    margin-bottom: 32px;
}

/* Admin Page */
.admin-page {
    padding-bottom: 32px;
}

.admin-section {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.admin-section h2 {
    font-size: 1.125rem;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-200);
}

.admin-section h3 {
    font-size: 1rem;
    color: var(--gray-700);
    margin-bottom: 8px;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--gray-100);
    border-radius: var(--border-radius);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-600);
    text-transform: uppercase;
}

.users-list, .logs-list {
    margin-top: 16px;
}

.user-item, .log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--gray-100);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
}

.user-info, .log-info {
    flex: 1;
}

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

.user-role {
    font-size: 0.75rem;
    color: var(--gray-600);
}

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

.user-actions .btn {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.log-action {
    font-weight: 600;
    color: var(--primary);
}

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

.export-docs {
    background: var(--gray-100);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.export-docs code {
    background: var(--gray-200);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.export-docs ul {
    margin: 8px 0;
    padding-left: 20px;
}

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

.export-form .form-group {
    flex: 1;
    min-width: 150px;
    margin-bottom: 0;
}

.query-result {
    margin-top: 16px;
    padding: 12px;
    background: var(--gray-100);
    border-radius: var(--border-radius);
    font-family: monospace;
    font-size: 0.875rem;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

.query-result pre {
    white-space: pre-wrap;
    word-break: break-word;
}

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

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

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

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

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading p {
    margin-top: 16px;
    color: var(--gray-600);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-content.modal-large {
    max-width: 500px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* Permissions checkboxes */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    max-height: 150px;
    overflow-y: auto;
}

.checkbox-group-scroll {
    max-height: 200px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"]:disabled {
    opacity: 0.5;
}

.form-help {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 12px;
}

#permissions-section h4 {
    margin: 16px 0 8px 0;
    color: var(--primary);
    font-size: 1rem;
}

/* Small buttons for user actions */
.btn-small {
    padding: 6px 10px;
    font-size: 0.9rem;
    min-width: auto;
}

.user-actions {
    display: flex;
    gap: 6px;
}

/* Responsive */
@media (max-width: 480px) {
    .question-text {
        font-size: 1.25rem;
    }
    
    .btn-answer {
        font-size: 1.25rem;
        padding: 20px;
    }
}

/* Print styles */
@media print {
    #header, .menu, .sync-indicator {
        display: none;
    }
    
    #main {
        max-width: 100%;
        padding: 0;
    }
}
