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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.hidden {
    display: none !important;
}

/* Screen reader only - visible to password managers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

header p {
    color: #666;
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.user-info span {
    color: #666;
}

.logout-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.logout-btn:hover {
    background: #e9ecef;
}

.admin-link {
    color: #007bff;
    text-decoration: none;
}

.admin-link:hover {
    text-decoration: underline;
}

/* Auth Section */
.auth-section {
    max-width: 400px;
    margin: 4rem auto;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form input {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    border-color: #007bff;
}

.auth-form button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-form button:hover {
    background: #0056b3;
}

.auth-form button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.auth-error {
    color: #dc3545;
    font-size: 0.875rem;
    text-align: center;
}

/* Submit Form */
.submit-section {
    margin-bottom: 2rem;
}

#submit-form {
    display: flex;
    gap: 0.5rem;
}

#youtube-url {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

#youtube-url:focus {
    border-color: #007bff;
}

button[type="submit"] {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

button[type="submit"]:hover {
    background: #0056b3;
}

button[type="submit"]:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Admin Section */
.admin-actions {
    margin-bottom: 2rem;
}

.create-user-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.create-user-form input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
}

.create-user-form input[type="text"]:focus {
    border-color: #007bff;
}

.admin-checkbox {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
}

.admin-checkbox input {
    cursor: pointer;
}

.create-user-form button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.create-user-form button:hover {
    background: #218838;
}

.create-user-form button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* User Item */
.user-item {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-item:last-child {
    border-bottom: none;
}

.user-name {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-time {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.25rem;
}

.admin-badge {
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    background: #007bff;
    color: white;
    border-radius: 999px;
    text-transform: uppercase;
}

.change-pw-badge {
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    background: #ffc107;
    color: #333;
    border-radius: 999px;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
}

.reset-pw-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.reset-pw-btn:hover {
    background: #e9ecef;
}

.delete-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

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

/* Copyable Code Display */
.copyable-code {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.temp-password {
    flex: 1;
    display: block;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    font-family: monospace;
    font-size: 1.1rem;
    text-align: center;
    user-select: all;
    word-break: break-all;
}

.copy-inline-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: #f8f9fa;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-inline-btn:hover {
    background: #e9ecef;
    color: #333;
}

.copy-inline-btn.copied {
    background: #d4edda;
    border-color: #28a745;
    color: #28a745;
}

.warning {
    color: #856404;
    background: #fff3cd;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-top: 1rem;
}

/* Jobs Section */
.jobs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.jobs-header h2 {
    font-size: 1.25rem;
}

.refresh-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

.refresh-btn:hover {
    background: #e9ecef;
}

.jobs-list {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.loading, .empty {
    padding: 2rem;
    text-align: center;
    color: #666;
}

/* Job Item */
.job-item {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.job-item:last-child {
    border-bottom: none;
}

.job-item:hover {
    background: #f8f9fa;
}

.job-item.clickable {
    cursor: pointer;
}

.job-info {
    flex: 1;
    min-width: 0;
}

.job-url {
    font-size: 0.875rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.job-time {
    font-size: 0.75rem;
    color: #999;
}

/* Status Badge */
.status-badge {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    text-transform: uppercase;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-processing {
    background: #cce5ff;
    color: #004085;
}

.status-completed {
    background: #d4edda;
    color: #155724;
}

.status-failed {
    background: #f8d7da;
    color: #721c24;
}

/* 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;
    padding: 1rem;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 1.125rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    white-space: pre-wrap;
    font-size: 0.9375rem;
    line-height: 1.8;
}

.modal-body.error {
    color: #721c24;
}

.modal-footer {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
}

.copy-btn, .download-btn {
    flex: 1;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.copy-btn {
    background: #f8f9fa;
    border: 1px solid #ddd;
    color: #333;
}

.copy-btn:hover {
    background: #e9ecef;
}

.download-btn {
    background: #007bff;
    border: none;
    color: white;
}

.download-btn:hover {
    background: #0056b3;
}

/* API Keys Section */
.api-keys-section {
    margin-top: 2rem;
}

.api-keys-section .create-user-form {
    margin-bottom: 1rem;
}

.key-item {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.key-item:last-child {
    border-bottom: none;
}

.key-name {
    font-weight: 500;
    font-family: monospace;
}

.key-time {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.25rem;
}

.key-actions {
    display: flex;
    gap: 0.5rem;
}

/* Responsive */
@media (max-width: 600px) {
    #submit-form {
        flex-direction: column;
    }

    button[type="submit"] {
        width: 100%;
    }

    .job-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .user-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .user-actions {
        width: 100%;
    }

    .user-actions button {
        flex: 1;
    }

    .create-user-form {
        flex-direction: column;
    }

    .create-user-form input[type="text"],
    .create-user-form button {
        width: 100%;
    }

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

    .key-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .key-actions {
        width: 100%;
    }

    .key-actions button {
        flex: 1;
    }
}
