/* static/css/style.css */

/* --- Variables and Global Styles --- */
:root {
    --gradient-start: #23B4E3;
    --gradient-end: #0E779C;
    --primary-color: #179dc1;
    --secondary-color: #2c2c2e; /* Dark gray for secondary elements */
    --background-color: #121212; /* Very dark main background */
    --card-bg-color: #1e1e1e;   /* Slightly lighter dark for cards */
    --text-color: #e4e6eb;       /* Light gray for primary text */
    --text-light-color: #b0b3b8; /* Dimmer gray for secondary text */
    --border-color: #3a3b3c;     /* Dark border color */
    --danger-color: #dc3545;
    --success-color: #28a745;
    --font-family: 'Inter', sans-serif;
    --border-radius: 8px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Adjusted for dark bg */
}

* {
    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;
    scrollbar-width: thin;
    scrollbar-color: #4a4a4a var(--background-color);
}

.container {
    max-width: 95%;
    margin: 0 auto;
    padding: 0 20px;
}

h1, h2, h3, h4, h5 {
    line-height: 1.2;
    margin-bottom: 0.75em;
}

p {
    margin-bottom: 1em;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--gradient-end);
}

/* --- Header --- */
.main-header {
    background: var(--card-bg-color);
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-img {
    height: 40px;
    width: auto;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* --- Main Content & Footer --- */
main {
    padding: 40px 0;
}

footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
    color: var(--text-light-color);
    font-size: 0.9em;
}


/* --- Buttons --- */
.button {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    text-align: center;
}

.button-primary {
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
}
.button-primary:hover {
    opacity: 0.9;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.button-secondary {
    background-color: var(--secondary-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.button-secondary:hover {
    background-color: #3a3a3c;
}

.button-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}
.button-outline:hover {
    background: rgba(35, 180, 227, 0.1);
}

.button-danger {
    background-color: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}
.button-danger:hover {
    background: rgba(220, 53, 69, 0.1);
}

.button-full {
    width: 100%;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-light-color);
    padding: 4px;
    line-height: 1;
}
.action-btn:hover { color: var(--primary-color); }
.action-btn.btn-delete-feature:hover, .action-btn.btn-delete-module:hover { color: var(--danger-color); }

/* --- Forms --- */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #2a2a2b; /* Dark input background */
    color: var(--text-color);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(35, 180, 227, 0.2);
}

textarea {
    resize: vertical;
}

/* Toggle Switch */
.form-group-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2a2a2b;
    padding: 1rem;
    border-radius: var(--border-radius);
}
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #555; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(22px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

#ai-thinking-toggle-container {
    margin-top: -1rem;
    margin-bottom: 1.5rem;
}

/* Image Upload Preview */
.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
.img-preview-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
}
.img-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--border-radius);
}
.img-delete-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 14px;
    cursor: pointer;
    line-height: 20px;
    text-align: center;
}

/* --- Cards --- */
.card {
    background: var(--card-bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 2rem;
    margin-bottom: 2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}
.card-header h3, .card-header h4 {
    margin-bottom: 0;
    word-break: break-word;
}
.card-description {
    color: var(--text-light-color);
    font-size: 0.9em;
}


/* --- Flash Messages --- */
.flash-messages { margin-bottom: 1rem; }
.flash { padding: 1rem; border-radius: var(--border-radius); }
.flash-success { background-color: #1c3d26; color: #a3e9b6; border: 1px solid #2a5c39;}
.flash-error { background-color: #442023; color: #f5c6cb; border: 1px solid #721c24;}


/* --- Login Page --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}
.login-box {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    background: var(--card-bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    text-align: center;
}
.login-box h2 { margin-bottom: 0.5rem; }
.login-box p { color: var(--text-light-color); margin-bottom: 2rem; }
.login-form { text-align: left; }
.login-info { margin-top: 1.5rem; font-size: 0.9em; color: var(--text-light-color); }

/* --- Dashboard Page --- */
.page-header {
    margin-bottom: 2rem;
}
.page-header .project-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}
.page-header p {
    font-size: 1.2rem;
    color: var(--text-light-color);
}
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}
.project-card {
    background: var(--card-bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: grab;
}
.project-card:active {
    cursor: grabbing;
}
.project-card-content {
    padding: 1.5rem;
    flex-grow: 1;
}
.project-card-content h3 { margin-bottom: 0.5rem; }
.project-card-content p { color: var(--text-light-color); font-size: 0.95em; }
.project-card-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
}
.project-card-actions a {
    margin-right: auto;
}

/* --- Dropdown Menu --- */
.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-toggle:after {
    content: ' ▼';
    font-size: 0.7em;
    margin-left: 5px;
}
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    background-color: var(--secondary-color);
    min-width: 220px;
    box-shadow: var(--box-shadow);
    z-index: 1;
    border-radius: var(--border-radius);
    padding: 0.5rem 0;
    border: 1px solid var(--border-color);
}
.dropdown-menu.show {
    display: block;
}
.dropdown-item {
    color: var(--text-color);
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    display: block;
    font-size: 0.95rem;
    white-space: nowrap;
}
.dropdown-item:hover {
    background-color: #3a3a3c;
    color: white;
}
.dropdown-menu hr {
    border: 0;
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
}


/* --- Project View Page --- */
.project-header { margin-bottom: 2rem; }
.project-title-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.project-description { font-size: 1.1rem; color: var(--text-light-color); max-width: 80ch; }
.feature-board-wrapper {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 1.5rem;
}
.feature-board {
    display: flex;
    gap: 1.5rem;
    min-height: 60vh;
    width: max-content;
}
.feature-card {
    width: 380px;
    flex-shrink: 0;
    background: #242526;
    border-radius: var(--border-radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    cursor: grab;
}
.feature-card:active { cursor: grabbing; }

.add-feature-card {
    width: 350px;
    flex-shrink: 0;
    align-self: flex-start;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    background: none;
    cursor: pointer;
    transition: background-color 0.2s;
}
.add-feature-card:hover { background-color: var(--secondary-color); }
#add-feature-btn { width: 80%; }

.module-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
    flex-grow: 1;
    min-height: 100px; /* Drop zone */
    padding: 0.5rem;
    background-color: #3a3b3c;
    border-radius: var(--border-radius);
}
.module-card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: grab;
}
.module-card:active { cursor: grabbing; }

.io-summary {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: var(--text-light-color);
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.add-module-btn {
    width: 100%;
    margin-top: 1rem;
}

/* Carousel */
.carousel {
    overflow: hidden;
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
}
.card-carousel { margin: -1rem -1rem 1rem -1rem; border-radius: var(--border-radius) var(--border-radius) 0 0; }
.carousel-inner {
    display: flex;
    transition: transform 0.5s ease;
}
.carousel-item {
    min-width: 100%;
    box-sizing: border-box;
}
.carousel-item img {
    width: 100%;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

/* Drag and Drop feedback */
.sortable-ghost {
    opacity: 0.4;
    background: rgba(35, 180, 227, 0.2);
}
.sortable-chosen {
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

/* Modal Styles */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1040;
}
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 100%;
    max-height: 90vh;
    background: var(--card-bg-color);
    border-radius: var(--border-radius);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-light-color);
}
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}
.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: right;
}
.modal-footer .button {
    margin-left: 0.5rem;
}
.selective-import-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    background: #2a2a2b;
}

.io-details-container {
    display: flex;
    gap: 1.5rem;
}
.io-details-column { flex: 1; }
.io-list-detailed { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem;}
.io-item-detailed {
    background: #2a2a2b;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}


.io-management-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.io-details-container {
    display: flex;
    gap: 1.5rem;
}
.io-details-column { flex: 1; }
.io-list-detailed {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}
.io-item-detailed {
    background: #2a2a2b;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.io-item-detailed-title {
    font-weight: 500;
    word-break: break-all;
}
.io-item-detailed .description {
    font-size: 0.85em;
    color: var(--text-light-color);
    margin-top: 4px;
}
.io-item-detailed .actions button {
    margin-left: 8px;
}
.io-form {
    background: #2a2a2b;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-top: 1rem;
}
.connected-input-source {
    font-size: 0.8em;
    font-style: italic;
    color: #0E779C;
    cursor: pointer;
    text-decoration: underline;
}
.io-connection-fields {
    padding: 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
    margin-top: 1rem;
}
.io-connection-fields label {
    font-size: 0.9em;
}
.button-small {
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* --- Diagram Container --- */
.diagram-container {
    text-align: center;
    padding: 2rem;
}
.diagram-container .mermaid {
    margin: 0 auto;
}


/* --- Custom Scrollbar Styles --- */
/* For Webkit browsers (Chrome, Safari, Edge) */
body::-webkit-scrollbar, .feature-board-wrapper::-webkit-scrollbar, .modal::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

body::-webkit-scrollbar-track, .feature-board-wrapper::-webkit-scrollbar-track, .modal::-webkit-scrollbar-track {
    background: var(--background-color);
}

body::-webkit-scrollbar-thumb, .feature-board-wrapper::-webkit-scrollbar-thumb, .modal::-webkit-scrollbar-thumb {
    background-color: #4a4a4a;
    border-radius: 20px;
    border: 3px solid var(--background-color);
}

body::-webkit-scrollbar-thumb:hover, .feature-board-wrapper::-webkit-scrollbar-thumb:hover, .modal::-webkit-scrollbar-thumb:hover {
    background-color: #6a6a6a;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .feature-board-wrapper {
        overflow-x: hidden;
    }
    .feature-board {
        flex-direction: column;
        width: 100%;
        gap: 1rem;
        min-height: unset;
    }
    .feature-card, .add-feature-card {
        width: 100%;
        cursor: default;
    }
    .feature-card:active {
        cursor: default;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .page-header .project-title-bar {
        flex-direction: column;
        align-items: flex-start;
    }
}