:root {
    --slots-per-day: 24;
    --bg-color: #f0f0f0;
    --text-color: #000;
    --button-bg: #007bff;
    --button-text: #fff;
    --module-bg: #fff;
    --border-color: #ccc;
}

body.dark-mode {
    --bg-color: #333;
    --text-color: #fff;
    --button-bg: #66b0ff;
    --button-text: #000;
    --module-bg: #444;
    --border-color: #555;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: all 0.3s ease;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
}

#main-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-panel {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 200px;
}

.bottom-controls {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    min-width: 200px;
}

.control-module {
    background-color: var(--module-bg);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 5px;
    flex: 1;
    min-width: 200px;
}

button, select, input[type="text"], input[type="color"], input[type="file"] {
    margin: 5px 0;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--button-bg);
    color: var(--button-text);
    font-size: 14px;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

button:hover, select:hover {
    background-color: #0056b3;
    color: #fff;
}

body.dark-mode button:hover, body.dark-mode select:hover {
    background-color: #99c7ff;
    color: #000;
}

input[type="text"], input[type="color"], input[type="file"] {
    background-color: var(--module-bg);
    color: var(--text-color);
}

.content-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#categories {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
}

#grid {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    overflow: auto;
    min-height: 400px;
}

.day {
    display: flex;
    flex-direction: column-reverse;
    height: 100%;
}

.slot {
    position: relative;
    flex: 1;
    border: 1px solid var(--border-color);
    height: calc(100% / var(--slots-per-day)); /* Standard spacing for 24 slots */
    min-height: 25px; /* Minimum height for readability */
    box-sizing: border-box;
    cursor: pointer;
}

.slot-time {
    font-size: 10px;
    color: var(--text-color);
    position: absolute;
    top: 2px;
    left: 2px;
}

.block {
    position: absolute;
    width: 100%;
    height: 100%; /* Match slot height */
    z-index: 1;
    cursor: move;
    box-sizing: border-box;
    padding: 2px;
}

.block-label {
    font-size: 10px;
    color: #fff;
    text-align: center;
    white-space: nowrap; /* Force single line */
    overflow: hidden; /* Hide overflow */
    text-overflow: ellipsis; /* Add ellipsis for overflow */
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 3px;
    width: 100%;
    box-sizing: border-box;
    display: block; /* Ensure it takes full width */
}

.day-label {
    text-align: center;
    font-weight: bold;
    padding: 5px;
    color: var(--text-color);
}

.category {
    display: inline-block;
    padding: 5px 10px;
    margin: 2px;
    border-radius: 4px;
    cursor: pointer;
    color: #fff;
    background-color: #007bff;
}

.category.selected {
    border: 2px solid var(--text-color);
    background-color: #0056b3;
}

#legend {
    margin-top: 10px;
}

.legend-item {
    display: inline-block;
    margin-right: 10px;
}

.legend-item span {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 5px;
}

#report {
    margin-top: 20px;
    padding: 10px;
    background-color: var(--module-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

#summaryTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

#summaryTable th, #summaryTable td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
    color: var(--text-color);
}

#pieChartActivity, #pieChartMindset {
    margin-top: 10px;
    max-width: 100%;
}

#day-type-preview {
    margin: 10px 0;
    padding: 5px;
    border: 1px dashed var(--border-color);
    min-height: 50px;
}

#day-checkboxes {
    margin: 10px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

#day-checkboxes label {
    margin-right: 10px;
}

.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);
    padding-top: 60px;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-image {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

.modal-caption {
    margin-top: 10px;
    text-align: center;
}

#mindset-thumbnail {
    width: 100px;
    height: 100px;
    cursor: pointer;
    margin-left: auto; /* Push to the right */
    margin-top: 10px;
}

#mindset-thumbnail img {
    width: 100%;
    height: 100%;
}

/* Responsive Design */
@media (max-width: 900px) {
    #main-content {
        flex-direction: column;
    }
    #grid, #mindset-thumbnail {
        width: 100%;
    }
    .control-panel, .bottom-controls {
        flex-direction: column;
    }
    .control-module {
        min-width: 0;
    }
    #categories {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    #mindset-thumbnail {
        margin-left: 0; /* Center on small screens */
    }
}

@media (min-width: 901px) {
    #main-content {
        flex-direction: column;
    }
    .control-panel, .bottom-controls {
        flex-direction: row;
        align-items: flex-start;
    }
    #categories {
        justify-content: center;
        flex-wrap: wrap;
    }
    #mindset-thumbnail {
        margin-left: auto;
    }
}
