/* Custom Styles */

.screen {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

.screen.active {
    display: block;
}

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

/* Buttons */
.btn-primary {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(to right, #6366f1, #8b5cf6);
    color: white;
    font-weight: 600;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: white;
    color: #374151;
    font-weight: 600;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* Loading Spinner */
.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e5e7eb;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Modern Text Input */
.text-input {
    width: 100%;
    padding: 1.25rem 1.5rem;
    font-size: 1.125rem;
    background: linear-gradient(to bottom, #fafafa, #ffffff);
    border: 2px solid #e5e7eb;
    border-radius: 1rem;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.text-input:hover {
    border-color: #c7d2fe;
    background: white;
}

.text-input:focus {
    border-color: #6366f1;
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), 0 4px 12px rgba(99, 102, 241, 0.15);
}

.text-input::placeholder {
    color: #9ca3af;
}

/* Question Options - Single Select */
.option-card {
    padding: 1.25rem 1.5rem;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.option-card:hover {
    border-color: #a5b4fc;
    background: linear-gradient(to bottom right, #eef2ff, #faf5ff);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.option-card.selected {
    border-color: #6366f1;
    background: linear-gradient(to bottom right, #eef2ff, #f5f3ff);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2), inset 0 0 0 1px rgba(99, 102, 241, 0.1);
}

.option-card.selected::before {
    content: '✓';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
}

.option-card input {
    display: none;
}

/* Checkbox Options - Multiple Select */
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.checkbox-option:hover {
    border-color: #a5b4fc;
    background: linear-gradient(to bottom right, #eef2ff, #faf5ff);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.checkbox-option.selected {
    border-color: #6366f1;
    background: linear-gradient(to bottom right, #eef2ff, #f5f3ff);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.checkbox-option .checkbox {
    width: 26px;
    height: 26px;
    border-radius: 0.5rem;
    border: 2px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
    background: white;
}

.checkbox-option:hover .checkbox {
    border-color: #a5b4fc;
}

.checkbox-option.selected .checkbox {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.checkbox-option .checkbox svg {
    width: 14px;
    height: 14px;
    color: white;
    opacity: 0;
    transition: all 0.2s ease;
    transform: scale(0.5);
}

.checkbox-option.selected .checkbox svg {
    opacity: 1;
    transform: scale(1);
}

.checkbox-option span {
    font-size: 1.0625rem;
    color: #374151;
    font-weight: 500;
}

.checkbox-option.selected span {
    color: #4338ca;
}

/* Day Tabs */
.day-tabs {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem;
    background: #f1f5f9;
    border-radius: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    align-items: center;
}

.day-tab {
    flex: 0 0 auto; /* size to content, prevent stretching */
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: 0.75rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    appearance: none;
    line-height: 1.1;
}

.day-tab:hover {
    background: white;
    color: #6366f1;
}

.day-tab.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.day-tab-short {
    display: none;
}

.day-tab-full {
    display: block;
}

@media (max-width: 640px) {
    .day-tab-short { display: block; }
    .day-tab-full { display: none; }
    .day-tab { padding: 0.6rem 0.5rem; }
}

/* Day Contents */
.day-contents {
    min-height: 400px;
}

.day-content {
    display: none;
    animation: fadeSlideIn 0.4s ease;
}

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

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

/* Habits List */
.habits-list {
    display: block;
}

/* Habit Card - Clean Design */
.habit-card {
    display: grid;
    grid-template-columns: 24px 48px 1fr auto; /* checkbox, icon, content, category */
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    margin-bottom: 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-left: 4px solid var(--accent-color, #6366f1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.habit-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.habit-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 20px;
    grid-column: 2; /* ensure icon stays after checkbox */
}

/* Checkbox */
.habit-checkbox {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #c7d2fe; /* indigo-200 */
    border-radius: 6px;
    background: #fff;
    display: inline-block;
    justify-self: center;
    align-self: center;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.06s ease, background 0.2s ease, border-color 0.2s ease;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 12px 12px;
    grid-column: 1; /* explicitly first */
}
.habit-checkbox:hover {
    box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
}
.habit-checkbox:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(99,102,241,0.2);
}
.habit-checkbox:active {
    transform: scale(0.96);
}
.habit-checkbox:checked {
    border-color: transparent;
    background-color: var(--accent-color, #6366f1);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='white' d='M6.173 12.066L2.5 8.393l1.414-1.414 2.259 2.259 5.914-5.914 1.414 1.414z'/></svg>");
}

.habit-card-content {
    min-width: 0;
    grid-column: 3; /* explicitly after icon */
}

.habit-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.habit-card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.habit-card-time,
.habit-card-duration {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #6b7280;
    white-space: nowrap;
}

.habit-card-time svg,
.habit-card-duration svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.habit-card-category {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
    grid-column: 4;
    justify-self: end;
    align-self: center;
}

/* Completed state */
.habit-card.completed .habit-card-title {
    text-decoration: line-through;
    color: #9ca3af;
}
.habit-card.completed .habit-card-icon {
    filter: grayscale(0.2) brightness(0.95);
}
.habit-card.completed {
    opacity: 0.88;
}

@media (max-width: 640px) {
    .habit-card {
        grid-template-columns: 22px 40px 1fr; /* checkbox, icon, content */
        grid-template-rows: auto auto;
        padding: 16px;
    }
    .habit-card-icon {
        width: 40px;
        height: 40px;
        grid-row: 1;
    }
    .habit-card-content {
        grid-column: 3;
        grid-row: 1;
    }
    .habit-card-category {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: start;
        margin-top: 8px;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .day-card {
        margin-bottom: 1rem;
    }
    
    .day-card-header {
        padding: 0.5rem;
    }
    
    .option-card,
    .checkbox-option {
        padding: 1rem 1.25rem;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c7c7c7;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
