/* public/style.css */

/* --- General Styles --- */
.hidden { 
    display: none !important; /* Use important to override any other display properties */
}

#ui-container {
    width: 90%;
    max-width: 550px; /* A bit wider for better layout */
    padding: 30px 40px;
    border-radius: 20px; /* More rounded corners */
    text-align: center;
    /* The frosted glass effect is now on the start-screen specifically */
}

body {
    font-family: 'Poppins', sans-serif;
    color: #212529;
    background-color: #87CEFA;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

main {
    flex: 1;
    display: grid;
    place-items: center;
}

button {
    padding: 12px 24px;
    border: none;
    color: white;
    background: #007bff;
    cursor: pointer;
    border-radius: 12px; /* Matching rounded corners */
    font-size: 1.1rem; /* Slightly larger font */
    font-weight: bold;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

button:disabled {
    background: #adb5bd;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- YouTube Video --- */
.video-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    margin: 25px 0;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* --- Terms Modal --- */
#terms-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#terms-content {
    background-color: #fff;
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    text-align: center;
}

#terms-content h2 {
    font-size: 1.3rem;
    margin-top: 0;
    margin-bottom: 10px;
}

#terms-content > p {
    font-size: 1rem;
    margin-bottom: 20px;
}

#terms-agreement {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

#terms-agreement input {
    margin-right: 8px;
}

#terms-agreement label {
    font-size: 0.9rem;
    text-align: left;
    line-height: 1.3;
}

#view-terms-link {
    text-decoration: underline;
    color: #007bff;
    cursor: pointer;
}

#agree-btn {
    width: 100%;
    font-size: 1rem;
}

#terms-details {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    text-align: left;
    font-size: 0.8rem;
    line-height: 1.5;
    max-height: 40vh; /* Make the details scrollable if they are long */
    overflow-y: auto;
}

#terms-details h3 {
    font-size: 0.9rem;
    margin-top: 10px;
    margin-bottom: 5px;
}

/* --- Loader for Searching Screen --- */
.loader {
    border: 5px solid #f3f3f3; 
    border-top: 5px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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


/* --- Chat Screen --- */
#chat-screen {
    width: 100%;
}

#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap; /* Allow items to wrap on smaller screens */
}

#chat-limits {
    font-size: 0.8rem;
    color: #495057;
    background: #e9ecef;
    padding: 5px 10px;
    border-radius: 8px;
    margin-bottom: 5px; /* Add margin for wrapped elements */
}

#messages {
    height: 350px;
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow-y: scroll;
    padding: 15px;
    margin-bottom: 15px;
    text-align: left;
    display: flex;
    flex-direction: column;
    background: #fff;
}

#messages p {
    margin: 0 0 10px 0;
    padding: 8px 12px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
}

#messages p strong {
    display: block;
    margin-bottom: 2px;
    font-size: 0.8rem;
    color: #343a40;
}

/* You are now on the right, Stranger on the left */
#messages p:has(strong:contains(You)) {
    background-color: #007bff;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
#messages p:has(strong:contains(You)) strong { color: #e9ecef; }

#messages p:has(strong:contains(Stranger)) {
    background-color: #e9ecef;
    color: #212529;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

#messages p:has(strong:contains(System)) {
    background: none;
    color: #6c757d;
    font-style: italic;
    align-self: center;
    text-align: center;
    font-size: 0.9rem;
}


#message-form { display: flex; gap: 10px; }

#message-input {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 12px;
    font-size: 1rem;
}

#char-counter { text-align: right; font-size: 0.8rem; color: #6c757d; margin-top: 5px; }

#next-btn, #main-menu-btn, #cancel-search-btn {
    margin-top: 15px;
    background-color: #6c757d;
    width: auto; /* Allow button to size to content */
    padding: 10px 20px;
}

#chat-header #next-btn { margin-top: 0; background: #dc3545; }

#next-btn:hover, #main-menu-btn:hover, #cancel-search-btn:hover { background-color: #5a6268; }
#chat-header #next-btn:hover { background: #c82333; }


/* --- Analysis Screen --- */
#analysis-screen h2 { margin-top: 0; }
#analysis-screen > p { font-style: italic; margin-bottom: 20px; }

#vibe-scores-container { border-top: 1px solid #eee; padding-top: 15px; margin-top: 15px; }

#vibe-scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    text-align: left;
    margin-top: 15px;
}

.vibe-score {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    text-transform: capitalize;
    border: 1px solid #e9ecef;
}

#heaven-hell-scores {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    font-size: 1.1rem;
    font-weight: bold;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

#reconnect-btn {
    margin-top: 20px;
    background-color: #28a745;
}

#reconnect-btn:hover { background-color: #218838; }

#main-menu-btn { width: 100%; }

/* --- Footer --- */
footer {
    text-align: center;
    padding: 15px 0;
    color: #6c757d;
    font-size: 0.9rem;
}

/* --- Media Queries for Responsiveness --- */
@media (max-width: 768px) {
    #ui-container {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    #messages {
        height: 250px; /* Shorter message box for mobile keyboards */
    }

    button {
        padding: 10px 20px;
        font-size: 1rem;
    }

    #chat-header {
        flex-direction: column;
    }

    #chat-limits {
        margin-bottom: 10px;
    }

    #heaven-hell-scores {
        flex-direction: column;
        gap: 10px;
    }

    #message-form {
        flex-direction: column;
    }

    #message-form button {
        width: 100%;
    }
}
