/* styles.css */
:root {
    --primary-color: #4a90e2;
    --secondary-color: #f5a623;
    --background-color: #f4f7f9;
    --surface-color: #ffffff;
    --text-color: #333;
    --text-color-light: #666;
    --border-color: #e0e0e0;
    --error-color: #d0021b;
    --success-color: #28a745;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --border-radius: 8px;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* --- Utility Classes --- */
.hidden {
    display: none !important;
}

/* --- Authentication --- */
#auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
}

#auth-form-wrapper {
    width: 100%;
    max-width: 400px;
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.auth-toggle-link {
    text-align: center;
    margin-top: 1rem;
}

.auth-toggle-link button {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}

/* --- Main Application Layout --- */
#main-app {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100vh;
    overflow: hidden;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.app-header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#welcome-message {
    font-size: 0.9rem;
    color: var(--text-color-light);
}

/* --- Dashboard Grid --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1.2fr;
    gap: 1.5rem;
    padding: 1.5rem;
    overflow-y: auto;
    height: calc(100vh - 70px); /* Adjust based on header height */
}

.dashboard-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.section-header h2 {
    font-size: 1.2rem;
}

.section-content {
    padding: 1rem;
    overflow-y: auto;
    flex-grow: 1;
}

.section-content ul {
    list-style: none;
}

/* --- Cards (Projects & Tasks) --- */
.project-card, .task-card {
    background: #fdfdfd;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.project-card:hover, .task-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.project-card.selected {
    border-left: 4px solid var(--primary-color);
    background-color: #e9f2fc;
}

.task-card h4 {
    margin-bottom: 0.25rem;
}

.task-card .task-meta {
    font-size: 0.8rem;
    color: var(--text-color-light);
    display: flex;
    justify-content: space-between;
}

/* --- Task Details View --- */
#task-details-view .section-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.task-details-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.task-details-header h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.task-details-meta span {
    display: block;
    font-size: 0.9rem;
    color: var(--text-color-light);
    margin-bottom: 0.25rem;
}

#comments-list li {
    background: var(--background-color);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

#comments-list .comment-author {
    font-weight: bold;
    font-size: 0.8rem;
    color: var(--primary-color);
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* --- Buttons --- */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary:hover {
    background-color: #357abd;
}

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

.btn-danger {
    background-color: var(--error-color);
    color: white;
}
.btn-danger:hover {
    background-color: #b0021b;
}

.btn-icon {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-color-light);
}
.btn-icon:hover {
    color: var(--primary-color);
}


/* --- Modals --- */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    width: 90%;
    max-width: 500px;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.5rem;
}

.close-btn {
    color: #aaa;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* --- Responsive Design --- */

/* Tablet */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr 2fr;
        grid-template-rows: auto auto;
        grid-template-areas:
            "projects tasks"
            "details details";
    }
    #projects-section { grid-area: projects; }
    #tasks-section { grid-area: tasks; }
    #task-details-section { grid-area: details; }
}

/* Mobile */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "projects"
            "tasks"
            "details";
        padding: 1rem;
        gap: 1rem;
        height: calc(100vh - 100px); /* Adjust for larger header */
    }

    .dashboard-section {
        max-height: 40vh; /* Prevent sections from taking too much space */
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}