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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f7f6;
    color: #333;
    padding: 15px;
}

/* --- Login Overlay Styles --- */
#loginOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    /* Semi-transparent background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    /* Ensure it's on top */
}

#loginBox {
    background-color: #fff;
    padding: 30px 40px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    min-width: 300px;
    text-align: center;
}

#loginBox h2 {
    margin-bottom: 25px;
    color: #333;
}

#loginForm .form-group {
    margin-bottom: 15px;
    text-align: left;
}

#loginForm label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

#loginForm input[type="text"],
#loginForm input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#loginForm button {
    background-color: #3498db;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 10px;
    width: 100%;
}

#loginForm button:hover {
    background-color: #2980b9;
}

#loginError {
    margin-top: 15px;
    min-height: 1.2em;
    /* Prevent layout shift */
}


/* --- Main App Content --- */
.container {
    max-width: 800px;
    margin: 20px auto;
    background-color: #fff;
    padding: 25px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h1,
h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
}

h1 {
    font-size: 1.8em;
}

h2 {
    font-size: 1.5em;
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

/* Form Styling */
#panicForm {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

fieldset.form-group {
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 5px;
}

legend {
    padding: 0 10px;
    font-weight: bold;
    color: #34495e;
}

label {
    font-weight: 500;
    color: #555;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

input[type="datetime-local"] {
    min-height: 40px;
}

textarea {
    resize: vertical;
}

/* Radio & Checkbox Groups */
.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.radio-group label,
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

input[type="radio"],
input[type="checkbox"] {
    accent-color: #3498db;
    width: 1.1em;
    height: 1.1em;
}

/* Button Styling */
.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Container for buttons */

#submitBtn,
#cancelEditBtn {
    /* Style both buttons similarly */
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: background-color 0.3s ease;
    flex-grow: 1;
    /* Make buttons share space */
}

#submitBtn {
    background-color: #3498db;
}

#submitBtn:hover {
    background-color: #2980b9;
}

#submitBtn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

#cancelEditBtn {
    background-color: #e74c3c;
}

/* Red for cancel */
#cancelEditBtn:hover {
    background-color: #c0392b;
}


/* Status Message */
.status-message {
    text-align: center;
    margin-top: 10px;
    font-weight: bold;
    min-height: 1.2em;
}

.status-message.success {
    color: #27ae60;
}

.status-message.error {
    color: #c0392b;
}

/* History Section */
.history-section {
    margin-top: 40px;
}

.history-list {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.history-entry {
    background-color: #ecf0f1;
    border: 1px solid #dcdcdc;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
    /* For positioning buttons */
}

.history-entry h3 {
    font-size: 1.2em;
    color: #2c3e50;
    margin-bottom: 10px;
    border-bottom: 1px solid #bdc3c7;
    padding-bottom: 5px;
}

.history-entry p {
    margin-bottom: 8px;
    color: #555;
}

.history-entry p strong {
    color: #333;
    min-width: 150px;
    /* Adjusted min-width */
    display: inline-block;
}

/* Increased width for label */
.history-entry ul {
    list-style: disc;
    margin-left: 20px;
    margin-bottom: 8px;
}

.history-entry .meta {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-top: 15px;
    text-align: right;
    clear: both;
}

/* Use clear:both */

/* --- Added for Edit/PDF Buttons --- */
.history-entry-actions {
    /* Container for buttons inside history entry */
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
}

.history-entry .edit-btn,
.history-entry .download-pdf-btn {
    display: inline-block;
    color: white;
    padding: 4px 8px;
    /* Smaller padding */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    /* Smaller font */
    transition: background-color 0.3s ease;
}

.history-entry .edit-btn {
    background-color: #f39c12;
}

/* Orange */
.history-entry .edit-btn:hover {
    background-color: #d35400;
}

.history-entry .download-pdf-btn {
    background-color: #16a085;
}

/* Teal */
.history-entry .download-pdf-btn:hover {
    background-color: #117e67;
}

.history-entry .download-pdf-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

/* --- End Edit/PDF Button CSS --- */


/* Mobile Responsiveness */
@media (max-width: 600px) {
    .container {
        margin: 10px auto;
        padding: 15px;
    }

    h1 {
        font-size: 1.5em;
    }

    h2 {
        font-size: 1.3em;
    }

    #submitBtn,
    #cancelEditBtn {
        font-size: 1rem;
        padding: 10px 15px;
    }

    .history-entry p strong {
        min-width: 110px;
    }

    /* Adjust label width */
    .history-entry-actions {
        position: static;
        float: right;
        margin-top: 10px;
    }

    /* Stack buttons below on small screens */
    .history-entry .meta {
        text-align: left;
        margin-top: 10px;
    }

    /* Align meta left below buttons */
}