/* --- Global Styles & Variables --- */
:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: #9b59b6; /* A nice purple */
    --primary-color-light: #a569bd;
    --text-color: #e0e0e0;
    --text-color-secondary: #a0a0a0;
    --border-color: #333333;
    --font-family: 'Noto Sans SC', sans-serif;
    --border-radius: 12px;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* --- App Layout --- */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-speed) ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-weight: 700;
    font-size: 1.5rem;
    text-align: center;
}

.nav-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.5rem;
    color: var(--text-color-secondary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: background-color var(--transition-speed), color var(--transition-speed), border-left-color var(--transition-speed);
}

.nav-list a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

.nav-list a.active {
    background-color: rgba(155, 89, 182, 0.1);
    color: var(--primary-color-light);
    border-left-color: var(--primary-color);
    font-weight: 700;
}

.nav-list .nav-progress {
    font-size: 0.8rem;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

.main-content {
    flex-grow: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
}

.main-header {
    margin-bottom: 2rem;
}

.main-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

.main-header p {
    color: var(--text-color-secondary);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* --- Progress Bar --- */
.progress-container {
    margin-top: 2rem;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-color-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background-color: var(--surface-color);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-inner {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), #8e44ad);
    border-radius: 6px;
    transition: width var(--transition-speed) ease-out;
}

/* --- Clothing List Card --- */
#clothing-list-container .card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.card-header h3 {
    font-size: 1.75rem;
    font-weight: 700;
}

.card-header .card-progress {
    font-size: 1rem;
    color: var(--text-color-secondary);
    font-weight: 500;
}

.clothing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

/* --- Custom Checkbox --- */
.form-check {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    padding: 0.75rem 1rem;
    background-color: var(--bg-color);
    border-radius: 8px;
    transition: background-color var(--transition-speed);
}

.form-check-label-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-grow: 1;
    padding-left: 2.5rem; /* Keep space for the custom checkbox */
    position: relative;
}

.form-check:hover {
    background-color: #2a2a2a;
}

.form-check-input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.form-check-label {
    font-size: 0.95rem;
    color: var(--text-color);
}
.form-check-label span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-color-secondary);
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: var(--bg-color);
    border: 2px solid var(--text-color-secondary);
    border-radius: 4px;
    transition: all var(--transition-speed);
}

.form-check-input:checked ~ .checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-input:checked ~ .form-check-label-container .form-check-label {
    text-decoration: line-through;
    color: var(--text-color-secondary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

.form-check-input:checked ~ .checkmark:after {
    display: block;
}

/* --- Placeholders & Loaders --- */
.placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 50vh;
    color: var(--text-color-secondary);
    font-size: 1.2rem;
}

.loader {
    border: 4px solid var(--border-color);
    border-radius: 50%;
    border-top: 4px solid var(--primary-color);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 3rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Responsive Design --- */
@media (max-width: 992px) {
    .main-content {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .nav-list {
        display: flex;
        overflow-x: auto;
        padding: 0.5rem 1rem;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .nav-list::-webkit-scrollbar {
        display: none;
    }
    .nav-list a {
        flex-shrink: 0;
        border-left: none;
        border-bottom: 4px solid transparent;
        border-radius: 8px;
        margin: 0 0.25rem;
    }
    .nav-list a.active {
        border-bottom-color: var(--primary-color);
    }
    .main-content {
        padding: 1.5rem;
    }
    .main-header h1 {
        font-size: 2rem;
    }
}

/* --- Detail Button --- */
.detail-button {
    background-color: var(--surface-color);
    color: var(--text-color-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    margin-left: 1rem;
    flex-shrink: 0;
}

.detail-button:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}


/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    pointer-events: none;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform var(--transition-speed) ease;
}

.modal-overlay.visible .modal-content {
    transform: scale(1);
}

.close-button {
    align-self: flex-end;
    padding: 0.5rem 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color-secondary);
    cursor: pointer;
    transition: color var(--transition-speed);
}

.close-button:hover {
    color: var(--text-color);
}

.modal-body {
    display: flex;
    flex-grow: 1;
    padding: 0 1.5rem 1.5rem;
    overflow: hidden;
}

.modal-info {
    width: 25%; /* Adjust width */
    padding-right: 1.5rem;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    flex-shrink: 0;
}

.modal-main-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 0 1.5rem;
    overflow: hidden;
}

.modal-canvas-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Prevents canvas from overflowing */
    width: 100%; /* Ensure it takes full width of the panel */
}

#modal-canvas {
    /* Styles will be dynamically applied by JS based on container size */
    /* object-fit does not apply to canvas */
    object-fit: contain;
    /* image-rendering will be set to pixelated or crisp-edges in JS */
}


.modal-info h3 {
    font-size: 1.5rem;
    color: var(--primary-color-light);
    margin-bottom: 1rem;
}

.modal-info p {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: var(--text-color);
}

.modal-info strong {
    color: var(--text-color-secondary);
}

.modal-external-link-container {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    width: 100%;
    text-align: center;
    flex-shrink: 0; /* Prevent it from shrinking */
    margin-top: auto; /* Pushes it to the bottom of the panel */
}

.modal-external-link-container p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: var(--text-color-secondary);
}

.modal-external-link-container a {
    background-color: var(--primary-color);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: background-color var(--transition-speed);
}

.modal-external-link-container a:hover {
    background-color: var(--primary-color-light);
}

/* --- Modal Color Options --- */
.modal-color-options-container {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.color-selector-group {
    margin-bottom: 1rem;
}

.color-selector-group h4 {
    margin-bottom: 0.5rem;
    color: var(--text-color-secondary);
    font-weight: 500;
    font-size: 1rem;
}

.color-options-div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
}

.color-button {
    border: 2px solid transparent;
    border-radius: 2px;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    text-align: center;
    color: white; /* Default text color for contrast */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7); /* Add shadow for readability */
}

.color-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.color-button.active {
    border-color: white;
    transform: scale(1.1);
    box-shadow: 0 0 15px white;
}

.color-button .capitalize {
    text-transform: capitalize;
}

.random-button {
    font-style: italic;
    background-color: var(--surface-color) !important; /* Override inline style */
    border: 2px solid var(--border-color);
    color: var(--text-color);
    text-shadow: none;
}