/* --- 1. CSS Variables & Global Styles --- */
:root {
    --bg-color: #1a1a2e;
    --surface-color: rgba(27, 27, 46, 0.5); /* Semi-transparent for glass effect */
    --border-color: rgba(255, 255, 255, 0.2);
    --text-primary: #EAEAEA;
    --text-secondary: #B3B3B3;
    --accent-primary: #9445f1;
    --accent-secondary: #4A00E0;
}

/* Keyframe animation for fade-in effect */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
    padding: 20px;
    /* Animated gradient background */
    background: linear-gradient(45deg, #16222A, #1a1a2e, #3A1C71);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}


/* --- 2. Layout & Main Card (Glassmorphism) --- */
/* Find the existing 'main' rule and change max-width */
main {
    max-width: 1400px; /* Make the main card wider */
    margin: 20px auto;
    padding: 30px 40px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); /* For Safari */
    animation: fadeIn 0.8s ease-out forwards;
}



/* --- 3. Typography & Icons --- */
h1 {
    text-align: center;
    font-weight: 700;
    font-size: 2.5rem;
    background: linear-gradient(90deg, #f8cdda, #c6a7f8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 40px;
}

h2 {
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 40px;
    color: var(--text-primary);
}

/* Styling for icons in headings */
h2 .fa-solid {
    margin-right: 12px;
    color: var(--accent-primary);
}

/* --- 4. Form Controls & Inputs --- */
#drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#drop-zone:hover, #drop-zone.dragover {
    border-color: var(--accent-primary);
    background-color: rgba(148, 69, 241, 0.1);
}

/* --- 5. Button Styles --- */
#analyze-btn {
    display: flex; /* Use flexbox to align icon and text */
    align-items: center;
    justify-content: center;
    gap: 10px; /* Space between icon and text */
    width: 100%;
    margin: 40px auto 20px auto;
    padding: 15px 20px;
    font-size: 18px;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#analyze-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 0, 224, 0.4);
}

/* Other styles remain largely the same, this just copies them over */
label { font-weight: 500; color: var(--text-secondary); }
p { color: var(--text-secondary); }
.config-item, .data-source-toggle { margin: 20px 0; display: flex; align-items: center; gap: 15px; }
input[type="number"] { background-color: var(--bg-color); border: 1px solid var(--border-color); border-radius: 5px; padding: 8px 12px; color: var(--text-primary); font-size: 14px; width: 60px; }
#status { text-align: center; font-style: italic; color: var(--text-secondary); margin-top: 20px; }
.hidden { display: none; }
#default-data-info, #data-requirements { background-color: rgba(0,0,0,0.2); padding: 5px 20px; border-radius: 8px; margin-top: 20px; border: 1px solid var(--border-color); }
footer { text-align: center; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border-color); color: #666; font-size: 14px; }
footer a { color: var(--accent-primary); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ### ADD THESE NEW RULES AT THE END OF THE FILE ### */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr; /* 3 columns, the last one is wider */
    gap: 30px; /* Space between the cards */
}

.step-card {
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.results-card {
    /* Make the results card span the full height potentially */
    display: flex;
    flex-direction: column;
}

#plot {
    flex-grow: 1; /* Allows the plot to fill available space */
    min-height: 450px;
}

/* ### ADD THESE NEW RULES FOR PERSONA CARDS ### */
#persona-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.persona-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    animation: fadeIn 0.5s ease-out forwards;
}

.persona-card h3 {
    margin-top: 0;
    color: var(--accent-primary);
}

.persona-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.persona-card ul {
    list-style-type: none;
    padding: 0;
    font-size: 13px;
}

.persona-card ul li {
    color: var(--text-secondary);
}

/* Style for the color dot in the persona card heading */
.color-dot {
    display: inline-block;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    margin-right: 10px;
    vertical-align: middle; /* Aligns the dot nicely with the text */
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ### ADD THESE NEW RULES FOR THE LOADER ### */

/* The overlay that covers the results area */
#loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(27, 27, 46, 0.8); /* Semi-transparent surface color */
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 12px; /* Match parent card's border-radius */
}

#loader-overlay p {
    margin-top: 20px;
    font-weight: 500;
    color: var(--text-primary);
}

/* The spinner itself */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top-color: var(--accent-primary); /* The spinning color */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* The animation keyframes for the spinning motion */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* We need to make the parent container position: relative */
.results-card {
    position: relative;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* ### ADD THESE NEW RULES FOR TOOLTIPS ### */

[data-tooltip] {
    position: relative; /* This is the anchor for the tooltip */
    cursor: help; /* Changes the cursor to a question mark */
    text-decoration: underline dotted var(--text-secondary); /* A subtle indicator */
}

/* The tooltip box itself - hidden by default */
[data-tooltip]::after {
    content: attr(data-tooltip); /* Use the attribute's text as content */
    position: absolute;
    left: 50%;
    bottom: 125%; /* Position it above the text */
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 500;
    width: 200px;
    text-align: center;
    opacity: 0; /* Hidden by default */
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 20;
}

/* Show the tooltip on hover */
[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ### ADD THESE NEW RULES FOR THE MODAL ### */

#info-btn {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s ease;
    vertical-align: middle;
}

#info-btn:hover {
    color: var(--accent-primary);
}

#modal-overlay {
    position: fixed; /* Sits on top of everything */
    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: 100;
    animation: fadeIn 0.3s ease-out forwards;
}

#modal-content {
    position: relative;
    padding: 30px 40px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: 600px;
}

#close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s ease;
}

#close-btn:hover {
    color: var(--text-primary);
}

/* ### ADD THESE NEW RULES FOR THE ENHANCED MODAL ### */

#modal-content {
    position: relative;
    padding: 30px 40px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: 600px;
    /* ### ADD THESE TWO LINES ### */
    max-height: 80vh; /* Set max height to 80% of the viewport height */
    overflow-y: auto; /* Add a vertical scrollbar only when needed */
}

/* Style for the upload guidelines text */
.upload-guideline {
    font-size: 13px;
    color: var(--text-secondary);
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    margin-top: 15px;
}

/* Final fix for persona description text being cut off */
.persona-card p {
    white-space: normal !important; /* Force text to wrap */
    overflow: visible !important;   /* Force overflowing text to be visible */
    text-overflow: clip !important; /* Force the prevention of '...' */
    line-height: 1.5;
}