/* Main Styles for Mental Models Constellation */

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

body {
    font-family: 'Arial', sans-serif;
    background-color: #0a0a0a;
    color: #ffffff;
    overflow: hidden;
    line-height: 1.6;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

/* Header Styles */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(180deg, rgba(20, 20, 40, 0.9) 0%, rgba(10, 10, 10, 0.8) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000; /* Increased z-index */
    position: relative;
    width: 100%; /* Ensure full width */
}

.app-header .app-title,
.app-header .app-subtitle {
    flex-grow: 1;
    text-align: center;
}

@media (max-width: 480px) {
    .app-header {
        padding: 10px 15px; /* Adjusted padding for mobile */
        justify-content: space-between; /* Keep space-between for mobile */
    }
}

.menu-button {
    display: block; /* Ensure the button is always displayed */
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000; /* Ensure it's on top */
    padding: 10px; /* Increased padding for easier tapping */
    position: absolute;
    left: 20px;
}

@media (max-width: 480px) {
    .app-header {
        padding: 10px 15px; /* Adjusted padding for mobile */
        justify-content: space-between; /* Keep space-between for mobile */
    }

    .app-header .app-title,
    .app-header .app-subtitle {
        text-align: center; /* Center text within remaining space */
        margin-left: 0; /* Remove extra margin */
    }

    .menu-button {
        order: -1; /* Place it at the beginning of flex items */
        margin-right: 10px; /* Space between button and title */
    }
}

/* Adjust controls panel for desktop */
.controls-panel {
    position: absolute;
    top: 120px;
    left: 20px; /* Default position */
    background: rgba(20, 20, 40, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    width: 250px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    z-index: 50;
    backdrop-filter: blur(10px);
    transition: left 0.3s ease-in-out; /* Add transition for smooth sliding */
}

.controls-panel.hide {
    left: -270px; /* Hide off-screen (width + padding + border) */
}

@media (min-width: 481px) { /* For desktop and larger tablets */
    .menu-button {
        order: -1; /* Place it at the beginning of flex items */
    }
}


.app-title {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #3498db, #9b59b6, #e74c3c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-subtitle {
    font-size: 1rem;
    color: #bdc3c7;
    font-weight: 300;
}

/* Controls Panel */
.controls-panel {
    position: absolute;
    top: 120px;
    left: 20px;
    background: rgba(20, 20, 40, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    width: 250px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.controls-panel::-webkit-scrollbar {
    width: 8px;
}

.controls-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.controls-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Search Container */
.search-container {
    margin-bottom: 25px;
    display: flex;
    align-items: center;
}

.search-input {
    flex-grow: 1;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    color: #ffffff;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: #3498db;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.3);
}

.search-button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 16px;
    transition: color 0.3s ease;
    margin-left: 10px;
    padding: 0 5px;
}

.search-button:hover {
    color: #3498db;
}

/* Search Results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(20, 20, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin-top: 10px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.search-results-header {
    padding: 15px;
    background: rgba(52, 152, 219, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: bold;
    color: #3498db;
}

.search-result-item {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.3s ease;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.search-result-item:last-child {
    border-bottom: none;
}

.result-name {
    font-weight: bold;
    margin-bottom: 5px;
    color: #ffffff;
}

.result-description {
    font-size: 0.9rem;
    color: #bdc3c7;
    margin-bottom: 5px;
    line-height: 1.4;
}

.result-category {
    font-size: 0.8rem;
    color: #95a5a6;
    font-style: italic;
}

mark {
    background: rgba(52, 152, 219, 0.3);
    color: #ffffff;
    padding: 2px 4px;
    border-radius: 3px;
}

.no-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(20, 20, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin-top: 10px;
    padding: 15px;
    text-align: center;
    color: #e74c3c;
    backdrop-filter: blur(10px);
}

/* Filter Container */
.filter-container {
    margin-bottom: 25px;
}

.filter-title {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #ecf0f1;
    font-weight: 300;
}

.filter-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 5px;
    transition: background 0.3s ease;
}

.filter-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.filter-item input[type='checkbox'] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.filter-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex: 1;
    font-size: 0.9rem;
    color: #bdc3c7;
}

.color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.show-all-button {
    width: 100%;
    padding: 10px;
    background: rgba(52, 152, 219, 0.2);
    border: 1px solid rgba(52, 152, 219, 0.5);
    border-radius: 5px;
    color: #3498db;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.show-all-button:hover {
    background: rgba(52, 152, 219, 0.3);
    border-color: #3498db;
}

.show-all-button.active {
    background: rgba(231, 76, 60, 0.2);
    border-color: rgba(231, 76, 60, 0.5);
    color: #e74c3c;
}

.show-all-button.active:hover {
    background: rgba(231, 76, 60, 0.3);
    border-color: #e74c3c;
}

/* Info Container */
.info-container {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.info-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: #95a5a6;
}

.info-item i {
    margin-right: 10px;
    width: 16px;
    text-align: center;
}

/* Constellation Container */
.constellation-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Details Panel Styles */
.details-panel {
    position: absolute;
    top: 120px;
    right: -400px; /* Initially hidden */
    width: 350px;
    max-height: calc(100vh - 140px);
    background: rgba(20, 20, 40, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    z-index: 50;
    backdrop-filter: blur(10px);
    transition: right 0.5s ease;
    display: flex;
    flex-direction: column;
}

.details-panel.show {
    right: 20px; /* Slide in */
}

@media (max-width: 768px) {
    .details-panel {
        width: 90%;
        right: -100%; /* Hide off-screen */
        left: 5%; /* Center it */
        top: 80px; /* Adjust top position */
        max-height: calc(100vh - 100px);
        transition: right 0.5s ease, left 0.5s ease;
    }

    .details-panel.show {
        right: 5%; /* Slide in to center */
        left: 5%;
    }
}

@media (max-width: 480px) {
    .details-panel {
        width: 100%;
        left: 0;
        right: 0;
        top: auto; /* Override top */
        bottom: -100%; /* Hide off-screen */
        max-height: 70vh; /* Take up 70% of viewport height */
        border-radius: 10px 10px 0 0; /* Rounded top corners */
        transition: bottom 0.5s ease;
    }

    .details-panel.show {
        bottom: 0; /* Slide up from bottom */
    }
}

.details-content-container {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}

.details-title {
    font-size: 1.5rem;
    font-weight: 300;
    color: #3498db;
    margin-bottom: 15px;
}

.details-description {
    font-size: 1rem;
    line-height: 1.6;
    color: #ecf0f1;
    margin-bottom: 15px;
}

.details-category {
    font-size: 0.9rem;
    color: #bdc3c7;
}

.category-label {
    font-weight: bold;
}

.category-value {
    font-style: italic;
}

/* History Panel Styles */
.history-panel {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-title {
    font-size: 1.2rem;
    font-weight: 300;
    color: #ecf0f1;
}

.history-header-buttons {
    display: flex;
    gap: 8px;
}

.clear-history-button {
    background: none;
    border: none;
    color: #95a5a6;
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.3s ease;
}

.clear-history-button:hover {
    color: #e74c3c;
}

.close-history-button {
    background: none;
    border: none;
    color: #95a5a6;
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.3s ease;
}

.close-history-button:hover {
    color: #3498db;
}

.history-list {
    list-style: none;
    padding: 0;
    max-height: 150px;
    overflow-y: auto;
}

.history-item {
    padding: 8px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
    font-size: 0.9rem;
    color: #bdc3c7;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.category-label {
    font-weight: bold;
    margin-right: 10px;
}

.category-value {
    font-style: italic;
}

/* Loading Container */
.loading-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: #bdc3c7;
    font-size: 1.1rem;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 15px;
    background: rgba(20, 20, 40, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: #95a5a6;
    z-index: 100;
    position: relative;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-title {
        font-size: 2rem;
    }

    .app-subtitle {
        font-size: 0.9rem;
    }

    .controls-panel {
        width: 250px;
        left: 10px;
        top: 100px;
        padding: 15px;
    }

    .search-input {
        font-size: 13px;
        padding: 8px 10px;
    }

    .search-button {
        font-size: 14px;
    }

    .filter-title {
        font-size: 1rem;
    }

    .filter-item label {
        font-size: 0.85rem;
    }

    .info-item {
        font-size: 0.8rem;
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
    }

    .modal-header {
        padding: 20px 20px 10px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 10px 5px;
    }

    .app-title {
        font-size: 1.5rem;
    }

    .app-subtitle {
        font-size: 0.7rem;
    }

    .controls-panel {
        position: fixed;
        top: 0;
        left: -100%; /* Hidden off-screen */
        width: 80%; /* Take up 80% of screen width */
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        border-left: none;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        padding: 15px;
        transition: left 0.3s ease-in-out;
        overflow-y: auto;
        z-index: 1001; /* Ensure it's above other elements */
    }

    .controls-panel.show {
        left: 0; /* Slide in */
    }

    .search-container {
        margin-bottom: 15px;
    }

    .search-input {
        font-size: 16px; /* Prevent zoom on focus */
        padding: 12px; /* Larger touch target */
    }

    .filter-container {
        margin-bottom: 15px;
    }

    .filter-item {
        padding: 12px; /* Larger touch target */
    }

    .filter-item input[type='checkbox'] {
        width: 24px; /* Larger checkbox */
        height: 24px;
        margin-right: 12px;
    }

    .info-container {
        padding-top: 15px;
    }

    .info-item {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }

    .constellation-container {
        height: 250px;
    }

    .details-panel {
        width: 100%;
        left: 0;
        right: 0;
        top: auto; /* Override top */
        bottom: -100%; /* Hide off-screen */
        max-height: 70vh; /* Take up 70% of viewport height */
        border-radius: 10px 10px 0 0; /* Rounded top corners */
        transition: bottom 0.5s ease;
        z-index: 1001; /* Ensure it's above other elements */
    }

    .details-panel.show {
        bottom: 0; /* Slide up from bottom */
    }

    .details-title {
        font-size: 1.4rem;
        padding: 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .details-description {
        font-size: 1rem;
        padding: 0 15px 15px;
        line-height: 1.5;
    }

    .details-category {
        font-size: 0.9rem;
        padding: 0 15px 15px;
    }

    .history-title {
        font-size: 1.2rem;
        padding: 15px 0 10px;
    }

    .history-item {
        font-size: 0.9rem;
        padding: 12px 15px;
    }

    .loading-text {
        font-size: 1rem;
    }

    .app-footer {
        padding: 8px;
        font-size: 0.7rem;
    }

    /* Add touch-friendly button styles */
    .menu-button {
        padding: 12px; /* Larger touch target */
        font-size: 20px;
    }

    .search-button {
        padding: 12px;
        font-size: 18px;
    }

    .show-all-button {
        padding: 12px;
        font-size: 16px;
    }

    .clear-history-button {
        padding: 8px;
        font-size: 16px;
    }
}
