/* Form Styles */
form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

input, select, button {
    padding: 10px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: var(--primary-hover);
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* List Styles */
ul {
    list-style-type: none;
    padding: 0;
}

li {
    background-color: #f9f9f9;
    margin-bottom: 10px;
    padding: 15px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Habit Item Styles */
.habit-info {
    flex-grow: 1;
    margin-bottom: 10px;
}

.habit-main {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
}

.habit-name {
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.habit-category {
    font-size: 0.8em;
    color: var(--text-muted);
}

.habit-streak {
    margin-top: 10px;
    font-weight: bold;
    color: var(--streak-color);
}

.habit-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

/* Category Color Dot */
.category-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Button Styles */
.track-btn {
    padding: 8px 16px;
    margin-right: 10px;
}

.track-btn.tracked {
    background-color: #cccccc;
}

.delete-btn, .edit-btn, .archive-btn {
    background-color: transparent;
    color: var(--text-muted);
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.delete-btn:hover {
    background-color: #ffe0e0;
    color: var(--danger-color);
}

.edit-btn:hover {
    background-color: #e0e7ff;
    color: #3b5998;
}

.archive-btn:hover {
    background-color: #fff3e0;
    color: #ff9800;
}

.icon-btn {
    background-color: transparent;
    color: var(--text-muted);
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
}

.icon-btn:hover {
    background-color: #f0f0f0;
}

/* Secondary button style */
.btn-secondary {
    background-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

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

.btn-danger:hover {
    background-color: #cc0000;
}

/* Error Message Styles */
.error {
    color: #D8000C;
    background-color: #FFD2D2;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 4px;
    display: none;
}

/* Stats Styles */
.stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    margin-top: 20px;
    padding: 10px;
    background-color: #e9e9e9;
    border-radius: 4px;
}

.stat {
    text-align: center;
    flex: 1 1 30%;
    margin: 10px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    line-height: 1.5;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
}

.modal-content a {
    color: #0f4286;
}

.modal-content form {
    margin-bottom: 0;
}

.modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

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

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Form group styling */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input,
.form-group select {
    width: 100%;
}

/* Color Picker */
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.selected {
    border-color: #333;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #333;
}

/* Drag and Drop */
.drag-handle {
    cursor: grab;
    padding: 4px 8px;
    color: #999;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.habit-item {
    transition: transform 0.2s, box-shadow 0.2s;
}

.habit-item.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.habit-item.drag-over {
    border-top: 2px solid var(--primary-color);
}

/* Archived habit styling */
.habit-item.archived {
    opacity: 0.6;
    background-color: #f0f0f0;
}

.habit-item.archived .habit-name {
    font-style: italic;
}

/* Collapsible Section */
.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.collapsible-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-muted);
}

.collapsible-content {
    display: none;
}

.collapsible-content.open {
    display: block;
}

.chevron {
    transition: transform 0.2s;
}

.chevron.open {
    transform: rotate(180deg);
}

/* Category management */
.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
    margin-bottom: 8px;
}

.category-item .category-dot {
    width: 16px;
    height: 16px;
}

.category-item .category-name {
    flex-grow: 1;
}

/* Export/Import buttons */
.data-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.data-actions button {
    flex: 1;
    min-width: 120px;
}

/* Confirmation dialog */
.confirm-dialog {
    text-align: center;
}

.confirm-dialog p {
    margin-bottom: 20px;
}

/* Media Queries for components */
@media (min-width: 768px) {
    li {
        flex-direction: row;
        align-items: center;
    }

    .habit-info {
        flex-grow: 1;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
    }

    .habit-main {
        flex-direction: row;
        justify-content: flex-start;
    }

    .habit-actions {
        margin-left: auto;
        display: flex;
        align-items: center;
    }

    .track-btn {
        margin-right: 10px;
    }

    #habit-form {
        flex-direction: row;
    }

    #habit-input {
        flex: 3;
    }

    #habit-category {
        flex: 1;
    }
}

@media screen and (max-width: 767px) {
    li {
        background: var(--card-background);
    }
}
