/* app/static/styles.css */

/* --- VARIABLES & RESET --- */
:root {
    --primary-color: #2c3e50;       /* Dark Slate Blue */
    --accent-color: #3498db;        /* Professional Blue */
    --success-color: #27ae60;       /* Green */
    --bg-color: #f4f7f9;            /* Light Blue-Gray Background */
    --panel-bg: #ffffff;            /* White */
    --text-color: #333333;
    --border-color: #e1e4e8;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 40px 20px;
}

.container {
    max-width: 950px;
    margin: 0 auto;
    background: var(--panel-bg);
    padding: 40px 60px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

/* --- HEADER --- */
header {
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 25px;
    margin-bottom: 35px;
    text-align: center;
}

header h1 {
    color: var(--primary-color);
    margin: 0 0 10px 0;
    font-weight: 700;
    letter-spacing: -0.5px;
}

header p {
    color: #7f8c8d;
    margin: 0;
    font-size: 1.1em;
}

footer {
    text-align: center;
    margin-top: 50px;
    font-size: 0.9em;
    color: #95a5a6;
    border-top: 1px solid var(--bg-color);
    padding-top: 20px;
}

/* --- FORM STYLING --- */
form {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.form-section {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    transition: box-shadow 0.2s ease;
}

.form-section:hover {
    box-shadow: var(--shadow-sm);
    border-color: #d1d5da;
}

.form-section h3 {
    margin-top: 0;
    color: var(--accent-color);
    border-bottom: 1px solid var(--bg-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
    font-size: 1.2em;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    font-weight: 600;
    font-size: 0.95em;
    color: var(--primary-color);
}

.help-text {
    font-size: 0.85em;
    color: #7f8c8d;
    margin: -4px 0 0 0;
}

input[type="text"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* --- BUTTONS --- */
button {
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button[type="submit"] {
    background-color: var(--success-color);
    color: white;
    padding: 15px 40px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    align-self: center;
    box-shadow: 0 4px 6px rgba(39, 174, 96, 0.2);
}

button[type="submit"]:hover {
    background-color: #219150;
    transform: translateY(-1px);
}

button[type="submit"]:active {
    transform: translateY(1px);
}

/* --- RESULT PAGE STYLING --- */

.result-section {
    margin-bottom: 40px;
}

/* The visual box that looks like an EHR note */
.formatted-note-display {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 40px; /* Increased padding for document feel */
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px; /* Slightly smaller for density */
    line-height: 1.6;
    color: #2c3e50;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
    min-height: 300px;
    white-space: normal; /* We use <br> for line breaks, so normal is fine */
}

/* 
   --- SMART CITATION TOOLTIPS --- 
   This interacts with the span generated in rendering.py
*/
.citation-trigger {
    border-bottom: 1px dotted #999; /* Subtle visual cue */
    cursor: help;                   /* Question mark cursor */
    position: relative;             /* Needed for absolute positioning of tooltip */
    transition: background-color 0.2s;
}

.citation-trigger:hover {
    background-color: #fff3cd; /* Light yellow highlight on hover */
    color: #000;
}

/* The Tooltip Box */
.citation-trigger::after {
    content: attr(data-tooltip); /* Dynamically grabs the citation text */
    
    /* Hidden by default */
    visibility: hidden;
    opacity: 0;
    
    /* Positioning */
    position: absolute;
    bottom: 125%; /* Floats above the text */
    left: 50%;
    transform: translateX(-50%); /* Centers it */
    
    /* Styling */
    background-color: #2c3e50;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    white-space: nowrap;
    z-index: 100;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    
    /* Animation */
    transition: opacity 0.2s ease-in-out, visibility 0.2s;
    pointer-events: none; /* Prevents tooltip from interfering with mouse */
}

/* The little arrow pointing down */
.citation-trigger::before {
    content: "";
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: #2c3e50 transparent transparent transparent;
    z-index: 100;
    transition: opacity 0.2s;
}

/* Show on hover */
.citation-trigger:hover::after,
.citation-trigger:hover::before {
    visibility: visible;
    opacity: 1;
}

/* --- JSON & EXTRAS --- */
pre.json-output {
    background-color: #282c34;
    color: #abb2bf;
    border-radius: 8px;
    padding: 20px;
    overflow-x: auto;
    font-size: 0.85em;
    border: none;
}

details > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent-color);
    padding: 10px 0;
    user-select: none;
}

.back-link {
    display: inline-block;
    margin-top: 20px;
    text-decoration: none;
    color: #7f8c8d;
    font-weight: 600;
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 6px;
    transition: all 0.2s;
}

.back-link:hover {
    background-color: #fff;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.error-box {
    background-color: #fdf2f2;
    border: 1px solid #fab1b1;
    color: #c0392b;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.instruction {
    background-color: #e8f4fd;
    color: #2980b9;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 0.9em;
    margin-bottom: 15px;
    display: inline-block;
}

/* --- CHAT WIDGET STYLING --- */
.chat-container {
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.chat-history {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.chat-bubble {
    background-color: var(--panel-bg);
    border: 1px solid #d1d5da;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 15px;
    color: var(--text-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.chat-bubble strong {
    color: var(--accent-color);
    display: block;
    margin-bottom: 8px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-bubble p {
    margin: 0;
    line-height: 1.5;
}

.chat-input-wrapper {
    display: flex;
    gap: 15px;
}

.chat-input-wrapper input[type="text"] {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.2s;
}

.chat-input-wrapper input[type="text"]:focus {
    border-color: var(--accent-color);
    outline: none;
}

.chat-input-wrapper button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0 25px;
    border-radius: 6px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.chat-input-wrapper button:hover {
    background-color: #34495e;
}

.chat-input-wrapper button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}