/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;

    /* Category Colors */
    --cat-work: #3b82f6;
    --cat-health: #22c55e;
    --cat-learning: #a855f7;
    --cat-leisure: #f59e0b;
    --cat-personal: #ec4899;
    --cat-social: #06b6d4;
    --cat-other: #64748b;
    --cat-meal: #f97316;
    --cat-break: #94a3b8;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base Styles */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.card h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.card h2 .icon {
    font-size: 1.5rem;
}

/* Preferences Section */
.preferences-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.preference-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preference-item label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.preference-item input {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
}

.preference-item input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.preference-toggles {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.toggle-text {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Activity Input Form */
.activity-input-form {
    margin-bottom: 24px;
}

.input-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.time-preference-row {
    grid-template-columns: 1fr;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-group input,
.input-group select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--surface);
    transition: var(--transition);
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn .icon {
    font-size: 1.1rem;
}

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

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

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

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

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

.btn-generate {
    width: 100%;
    padding: 18px 24px;
    font-size: 1.2rem;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    color: white;
    border-radius: var(--radius-md);
}

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

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

/* Activity List */
.activity-list-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.activity-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-style: italic;
}

.activity-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--background);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    gap: 12px;
}

.activity-item:last-child {
    margin-bottom: 0;
}

.activity-category-badge {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-category-badge.work { background: var(--cat-work); }
.activity-category-badge.health { background: var(--cat-health); }
.activity-category-badge.learning { background: var(--cat-learning); }
.activity-category-badge.leisure { background: var(--cat-leisure); }
.activity-category-badge.personal { background: var(--cat-personal); }
.activity-category-badge.social { background: var(--cat-social); }
.activity-category-badge.other { background: var(--cat-other); }

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

.activity-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.priority-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.priority-badge.high {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.priority-badge.medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.priority-badge.low {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success-color);
}

.activity-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1.2rem;
    line-height: 1;
    transition: var(--transition);
}

.activity-remove:hover {
    color: var(--danger-color);
}

.activity-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Generate Section */
.generate-section {
    text-align: center;
}

.generate-hint {
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Routine Section */
.routine-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.routine-header h2 {
    margin-bottom: 0;
}

.routine-actions {
    display: flex;
    gap: 10px;
}

.routine-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px;
    background: var(--background);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.stat-item {
    flex: 1;
    min-width: 120px;
    text-align: center;
}

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

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 80px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 60px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding: 16px 20px;
    background: var(--background);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.timeline-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 3px solid var(--primary-color);
}

.timeline-item.category-work { border-left-color: var(--cat-work); }
.timeline-item.category-work::before { border-color: var(--cat-work); }

.timeline-item.category-health { border-left-color: var(--cat-health); }
.timeline-item.category-health::before { border-color: var(--cat-health); }

.timeline-item.category-learning { border-left-color: var(--cat-learning); }
.timeline-item.category-learning::before { border-color: var(--cat-learning); }

.timeline-item.category-leisure { border-left-color: var(--cat-leisure); }
.timeline-item.category-leisure::before { border-color: var(--cat-leisure); }

.timeline-item.category-personal { border-left-color: var(--cat-personal); }
.timeline-item.category-personal::before { border-color: var(--cat-personal); }

.timeline-item.category-social { border-left-color: var(--cat-social); }
.timeline-item.category-social::before { border-color: var(--cat-social); }

.timeline-item.category-other { border-left-color: var(--cat-other); }
.timeline-item.category-other::before { border-color: var(--cat-other); }

.timeline-item.category-meal { border-left-color: var(--cat-meal); }
.timeline-item.category-meal::before { border-color: var(--cat-meal); }

.timeline-item.category-break { border-left-color: var(--cat-break); }
.timeline-item.category-break::before { border-color: var(--cat-break); }

.timeline-time {
    position: absolute;
    left: -80px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
    width: 50px;
}

.timeline-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.timeline-title {
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-duration {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px 0;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

footer a:hover {
    color: var(--primary-color);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.export-options {
    display: flex;
    gap: 12px;
    margin: 16px 0;
    flex-wrap: wrap;
}

.btn-export {
    flex: 1;
    min-width: 100px;
    padding: 16px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    flex-direction: column;
    gap: 8px;
}

.btn-export:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.btn-export .icon {
    font-size: 1.5rem;
}

.export-preview {
    margin-top: 20px;
}

.export-preview textarea {
    width: 100%;
    height: 200px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.85rem;
    resize: vertical;
    margin-bottom: 12px;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .app-container {
        padding: 16px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .card {
        padding: 16px;
    }

    .preferences-grid {
        grid-template-columns: 1fr;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

    .routine-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .routine-actions {
        width: 100%;
    }

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

    .timeline {
        padding-left: 60px;
    }

    .timeline::before {
        left: 40px;
    }

    .timeline-time {
        left: -55px;
        width: 40px;
        font-size: 0.75rem;
    }

    .timeline-item::before {
        left: -25px;
    }

    .activity-actions {
        flex-direction: column;
    }

    .activity-actions .btn {
        width: 100%;
    }

    .stat-item {
        min-width: 80px;
    }

    .export-options {
        flex-direction: column;
    }

    .btn-export {
        width: 100%;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.timeline-item {
    animation: fadeIn 0.3s ease forwards;
}

.timeline-item:nth-child(1) { animation-delay: 0.05s; }
.timeline-item:nth-child(2) { animation-delay: 0.1s; }
.timeline-item:nth-child(3) { animation-delay: 0.15s; }
.timeline-item:nth-child(4) { animation-delay: 0.2s; }
.timeline-item:nth-child(5) { animation-delay: 0.25s; }
.timeline-item:nth-child(6) { animation-delay: 0.3s; }
.timeline-item:nth-child(7) { animation-delay: 0.35s; }
.timeline-item:nth-child(8) { animation-delay: 0.4s; }
.timeline-item:nth-child(9) { animation-delay: 0.45s; }
.timeline-item:nth-child(10) { animation-delay: 0.5s; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
