/* CSS Variables */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-elevated: #252542;
    --text: #ffffff;
    --text-muted: #9ca3af;
    --border: #374151;
    --radius: 16px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

#app {
    height: 100%;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.screen.exiting {
    transform: translateX(-100%);
}

/* Screen Header */
.screen-header {
    display: flex;
    align-items: center;
    padding: 20px;
    gap: 12px;
}

.screen-header h2 {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
}

.step-indicator {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.btn-back {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    margin: -8px;
}

/* Screen Content */
.screen-content {
    flex: 1;
    padding: 0 20px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Home Screen */
.home-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.app-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-subtitle {
    color: var(--text-muted);
    margin-bottom: 48px;
    font-size: 1.125rem;
}

.home-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 280px;
    margin-bottom: 32px;
}

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-large {
    padding: 18px 32px;
    font-size: 1.125rem;
}

.btn-small {
    padding: 10px 16px;
    font-size: 0.875rem;
}

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

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
}

.btn-text {
    background: none;
    color: var(--text-muted);
    padding: 8px;
}

.btn-text:hover {
    color: var(--text);
}

/* Option Grid (Task Types) */
.option-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.option-btn {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.option-btn:hover {
    border-color: var(--primary);
}

.option-btn.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Option List (Levels) */
.option-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.level-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    text-align: left;
}

.level-icon {
    font-size: 1.25rem;
    min-width: 60px;
}

.level-label {
    font-weight: 600;
    font-size: 1.125rem;
}

.level-desc {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-left: auto;
}

/* Option Row (State Selection) */
.option-row {
    display: flex;
    gap: 8px;
}

.option-row .option-btn {
    flex: 1;
    padding: 14px 8px;
}

.state-section {
    margin-bottom: 24px;
}

.state-section h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-muted);
}

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input,
.form-group textarea {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
}

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

/* Swipe Container */
.swipe-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

.card-stack {
    width: 100%;
    max-width: 340px;
    height: 400px;
    position: relative;
}

.swipe-card {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    padding: 24px;
    cursor: grab;
    user-select: none;
    touch-action: none;
    transition: transform 0.1s ease;
}

.swipe-card.dragging {
    cursor: grabbing;
    transition: none;
}

.swipe-card.swiping-left {
    background: linear-gradient(135deg, var(--bg-card), rgba(239, 68, 68, 0.2));
}

.swipe-card.swiping-right {
    background: linear-gradient(135deg, var(--bg-card), rgba(16, 185, 129, 0.2));
}

.card-type {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 16px;
    align-self: flex-start;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.card-desc {
    color: var(--text-muted);
    margin-bottom: 24px;
    flex: 1;
}

.card-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.card-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.swipe-instructions {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 340px;
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.swipe-left {
    color: var(--danger);
}

.swipe-right {
    color: var(--success);
}

/* Accepted Screen */
.accepted-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.accepted-icon {
    width: 80px;
    height: 80px;
    background: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin-bottom: 24px;
}

.accepted-container h2 {
    font-size: 1.75rem;
    margin-bottom: 24px;
}

.accepted-task {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 320px;
    margin-bottom: 32px;
    text-align: left;
}

.accepted-task .task-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.accepted-task .task-desc {
    color: var(--text-muted);
}

.accepted-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 280px;
}

/* Manage Tasks Screen */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

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

.task-item-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.task-item-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.task-item-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px;
}

.task-item-delete:hover {
    color: var(--danger);
}

/* No Tasks Message */
.no-tasks {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.no-tasks p {
    margin-bottom: 20px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-content {
    background: var(--bg-elevated);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 320px;
}

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

.modal-content input {
    width: 100%;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 20px;
}

.modal-content input:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

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

/* Utilities */
.hidden {
    display: none !important;
}

/* Safe areas for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
    .screen-header {
        padding-top: calc(20px + env(safe-area-inset-top));
    }

    .home-container {
        padding-top: calc(40px + env(safe-area-inset-top));
    }
}
