.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: var(--z-overlay, 200);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Confirmation Overlay - Higher Z-Index */
.confirm-overlay,
#confirm-overlay {
    z-index: var(--z-sheet, 300);
    background: rgba(0,0,0,0.8); /* Darker backdrop for emphasis */
}

.modal {
    background: var(--modal-bg);
    width: 90%;
    max-width: 400px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: slideUp var(--transition-slow, 0.3s) ease-out;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Modal Size Variants */
.modal.modal-small { max-width: 300px; }
.modal.modal-confirm { max-width: 350px; }
.modal.modal-about { max-width: 450px; }

/* Modal Footer Variants */
.modal-footer-stacked {
    flex-direction: column;
    gap: 10px;
}

.modal-footer-centered {
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
    margin-top: 10px;
}

/* Button Variants */
.btn-full-width { width: 100%; }
.btn-small { padding: 5px 10px; font-size: 0.8rem; }

/* Close Modal Button Icon Fix */
.close-modal img {
    filter: invert(0.5);
}

/* Icon Utility */
.icon-inverted { filter: invert(1); }

/* Form Group Header */
.form-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Character Counter */
.char-counter {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Required Indicator */
.required-indicator {
    color: var(--danger-color, #ff4444);
}

/* Quick Time Buttons */
.quick-time-buttons {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
}

/* About Modal Specific */
.modal-about .about-description {
    margin-bottom: 25px;
}

.modal-about .about-description p {
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 0.95rem;
}

.modal-about .about-creator {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.modal-about .about-creator h3 {
    font-size: 1rem;
    margin-bottom: 5px;
    color: var(--text-color);
}

.modal-about .creator-role {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.modal-about .social-links {
    display: flex;
    gap: 12px;
}

.modal-about .social-links .social-btn {
    text-decoration: none;
    color: var(--text-color);
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 5px;
}

.modal-about .made-by-text {
    color: var(--text-muted);
    font-size: 0.8rem;
    opacity: 0.7;
}

/* What's New Modal */
.no-updates-text {
    color: var(--text-muted);
    text-align: center;
}

/* Confirm Modal Header */
.confirm-header-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.confirm-header-content h2 {
    margin: 0;
}

/* Text Danger Color Utility */
.text-danger {
    color: var(--danger-color, #ff4444);
}

/* --- Individual Modal Styling --- */

/* 1. Configuration Modal */
#modal-config {
    max-width: 450px;
    background: var(--modal-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
#modal-config .modal-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 20px 25px;
}
#modal-config .modal-body {
    gap: 8px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
}
#modal-config .form-group label {
    color: var(--input-label);
    font-weight: 600;
    letter-spacing: 0.5px;
}
#modal-config input {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.15);
}

/* 2. Event Modal (Edit Day) */
#modal-event {
    max-width: 500px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
#modal-event .modal-header {
    padding: 16px;
}
#modal-event .modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 16px;
}
#modal-event .form-group {
    margin-bottom: 16px;
}
#modal-event textarea {
    min-height: 80px;
    background: rgba(255, 255, 255, 0.03);
}
#modal-event .emoji-picker-row {
    background: rgba(255, 255, 255, 0.02);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* 3. Time Limit Modal */
#modal-time-limit {
    max-width: 460px;
    background: #1a1a1a; /* Slightly lighter for focus */
    border: 1px solid var(--accent-color);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
#modal-time-limit .modal-header {
    border-bottom: none;
    padding-bottom: 0;
}
#modal-time-limit .modal-body {
    padding: 30px 20px 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0px;
}
#modal-time-limit .form-group {
    text-align: left;
}
#modal-time-limit label {
    font-size: 1rem;
    color: var(--input-label);
}
#modal-time-limit input {
    text-align: left;
    font-size: 1.2rem;
    width: 100%;
    height: 56px;
    margin: 0 auto;
    background: transparent;
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    color: var(--text-color);
    font-weight: bold;
    padding-left: 16px;
}
/* Hide Spinners */
#modal-time-limit input::-webkit-outer-spin-button,
#modal-time-limit input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
#modal-time-limit input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

#modal-time-limit #btn-save-time-limit {
    width: 100%;
}

/* 4. Manage Events Modal */
#modal-manage {
    max-width: 650px;
    height: 85vh;
    display: flex;
    flex-direction: column;
}
#modal-manage .modal-header {
    flex-shrink: 0;
    background: rgba(0,0,0,0.2);
}
#modal-manage .modal-body {
    padding: 0;
    flex-grow: 1;
    overflow-y: auto;
    background: rgba(0,0,0,0.1);
}
/* Custom Scrollbar for Manage List */
#modal-manage .modal-body::-webkit-scrollbar {
    width: 8px;
}
#modal-manage .modal-body::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
#modal-manage .modal-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

/* 5. Time Up Modal (Alarm) */
#modal-time-up {
    max-width: 420px;
    border: 2px solid #ff6a6a57;
    box-shadow: 0 0 50px rgba(255, 51, 51, 0.2);
    background: #110508;
}
#modal-time-up .modal-header {
    background: rgba(255, 51, 51, 0.15);
    color: #ff5858;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 51, 102, 0.123);
}
#modal-time-up .modal-header h2 {
    font-size: 1.4rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
#modal-time-up .modal-body {
    padding: 40px;
    text-align: center;
    color: #ffcccc;
    font-size: 1.2rem;
}
#modal-time-up .modal-footer {
    padding: 20px;
    background: rgba(255, 51, 102, 0.05);
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* 6. Confirmation Modal */
#modal-confirm {
    max-width: 400px;
    z-index: var(--z-modal, 301);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: var(--modal-confirm-bg, #151515);
}
#modal-confirm .modal-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px 20px;
}
#modal-confirm .modal-body {
    padding: 30px 25px;
    font-size: 1.1rem;
    line-height: 1.5;
    color: var(--text-color);
}
#modal-confirm .modal-footer {
    padding: 15px 25px 25px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Social Buttons in About Modal */
.social-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border: 1px solid rgba(255,255,255,0.05);
}

.social-btn:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.2);
}

.social-btn img {
    width: 18px;
    height: 18px;
    filter: invert(0.8);
    transition: filter 0.2s;
}

.social-btn:hover img {
    filter: invert(1);
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.close-modal { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
.modal-body {
    padding: 15px;
    overflow-y: auto;
}

#read-only-date {
    margin-bottom: 15px;
}

/* --- Restored Form Styles --- */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--input-label);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: var(--text-color);
    font-family: var(--font-main);
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--text-muted);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--input-placeholder);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.emoji-picker-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

#event-emoji {
    width: 51px;
    text-align: center;
    font-size: 1.2rem;
}

.quick-emojis {
    display: flex;
    gap: 8px;
}

.quick-emojis span {
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    border-radius: 5px;
    transition: background 0.2s;
}

.quick-emojis span:hover {
    background: rgba(255,255,255,0.1);
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Modal Action Buttons */
.modal-footer button {
    /* Fallback for buttons without classes, though most should have .btn-primary/secondary now */
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

/* Day View Tasks Section */
.day-view-tasks {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.day-view-tasks h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.day-view-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Task Card Style */
.day-view-list li {
    background: var(--sidebar-bg);
    border: 1px solid var(--accent-color);
    border-radius: 10px;
    padding: 14px 14px;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    gap: 12px; /* Consistent gap between immediate flex items */
}

/* Layout: Flag -- Title ---------------- Status --- Timer */

/* Target the flag */
.day-view-list li .task-flag {
    margin-right: 0;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.day-view-list li .task-flag img {
    width: 16px;
    height: 16px;
    display: block;
}

/* Target the title */
.day-view-list li .task-title {
    font-weight: 500;
    color: var(--text-color);
    margin-right: auto; /* This pushes the following elements to the right */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Target the status */
.day-view-list li .task-status {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    background: var(--bg-color);
    border: 1px solid var(--accent-color);
    border-radius: 6px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    text-align: center;
}

/* Target the timer */
.day-view-list li .task-timer {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Error States */
.input-error {
    border-color: var(--error-color, #ff3366) !important;
    box-shadow: 0 0 10px rgba(255, 51, 102, 0.3) !important;
}

.error-msg {
    color: var(--error-color, #ff3366);
    font-size: 0.85rem;
    margin-top: 8px;
    display: block;
    font-weight: 500;
}
