/* 1. GLOBAL FIX: Prevents padding from creating scrollbars */
* {
    box-sizing: border-box;
}

body {
    font-family: sans-serif;
    /* FIX: Changed fixed width to max-width so it's fluid */
    width: 100%;
    max-width: 600px; 
    margin: 0 auto; /* Center the body */
    padding: 15px;
    background-color: #f4f4f4;
}

.container {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100%; /* Ensure it fits parent */
}

h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

/* Context Box (Selected Text) */
.context-box {
    background-color: #eef2f5;
    border-left: 4px solid #0000AF;
    padding: 10px;
    margin-bottom: 20px;
    font-size: 0.9em;
    color: #555;
    /* FIX: Ensure long text wraps and doesn't push width */
    word-wrap: break-word; 
    overflow-wrap: break-word; 
}

.context-box strong {
    display: block;
    margin-bottom: 5px;
    color: #0000AF;
}

.context-box blockquote {
    margin: 0;
    font-style: italic;
    white-space: pre-wrap; 
    word-wrap: break-word;
    max-height: 80px;
    overflow-y: auto;
}

/* Form Elements */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
}

/* Quill Editor Container */
#editor-wrapper {
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
    background-color: white;
}

/* FIX: Ensure Toolbar buttons wrap on small screens */
.ql-toolbar {
    display: flex;
    flex-wrap: wrap; /* Allows buttons to drop to next line */
    background-color: #f9f9f9;
    border-bottom: 1px solid #ccc;
}

#editor-container {
    height: 150px;
    font-size: 14px;
    font-family: sans-serif;
}

/* Credits Info */
.credits-info {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 15px;
    text-align: right;
    font-weight: bold;
}

/* Buttons */
button {
    width: 100%;
    padding: 10px;
    border: none;
    background-color: #0000AF;
    color: white;
    font-size: 1em;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #000080;
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Message Box */
.message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
    display: none;
}
.message:not(:empty) {
    display: block;
}
.message.success {
    background-color: #d4edda;
    color: #155724;
}
.message.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* --- LIST FIX --- */
.ql-editor ol, .ql-editor ul {
    padding-left: 1.5em !important;
}
/* --- Action Buttons Row --- */
.action-buttons {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 5px;
}

/* Make the save button wider so it feels like the primary action */
.save-btn {
    flex: 2; 
    background-color: #0000AF;
    color: white;
    font-weight: bold;
    border: 1px solid #000080;
    height: 40px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}
.save-btn:hover {
    background-color: #000080;
}

/* The matching Red Close Button */
.close-btn { 
    flex: 1; 
    background-color: #E90014; 
    color: white; 
    border: 1px solid #D10014; 
    height: 40px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}
.close-btn:hover { 
    background-color: #D10014; 
}
/* --- MOBILE OPTIMIZATIONS --- */
@media screen and (max-width: 600px) {
    body {
        /* FIX: Reset widths to fit screen */
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        
        padding: 10px; /* Reduced padding for mobile */
        padding-top: 2vh; 
        padding-bottom: 80px; /* Space for scrolling */
    }

    /* Container adjustments */
    div, form, .container, .ql-container {
        width: 100% !important;
        max-width: 100% !important;
        box-shadow: none; /* Cleaner look on mobile */
    }

    /* --- Toolbar Protection --- */
    .ql-toolbar button {
        width: 32px !important; /* Touch friendly size */
        height: 32px !important;
        padding: 5px !important;
    }

    /* Make Inputs and Save Button Touch Friendly */
    input, select, textarea, button {
        font-size: 16px !important; /* Prevents zooming */
        padding: 12px !important;
    }
}