/* FMLS Residential Data Input Form Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.mls-number {
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* User Info / Authentication */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
}

.user-name {
    color: white;
    font-size: 0.9rem;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-right a.nav-links,
.header-right .nav-links a {
    color: white;
    text-decoration: none;
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 4px;
}

.header-right a.nav-links:hover,
.header-right .nav-links a:hover {
    background: rgba(255,255,255,0.3);
}

/* Drafts Section */
.drafts-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-top: none;
    margin-bottom: 2px;
}

.drafts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #f5f5f5;
    cursor: pointer;
    border-bottom: 1px solid #e0e0e0;
}

.drafts-header:hover {
    background: #eeeeee;
}

.drafts-header h3 {
    font-size: 1rem;
    font-weight: 500;
    color: #555;
    margin: 0;
}

.drafts-toggle-icon {
    font-size: 1.2rem;
    font-weight: bold;
    color: #666;
}

.drafts-content {
    padding: 15px 20px;
}

.drafts-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.drafts-actions input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
}

.btn-save-draft {
    background: #1976d2;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
}

.btn-save-draft:hover {
    background: #1565c0;
}

.drafts-list {
    max-height: 300px;
    overflow-y: auto;
}

.no-drafts {
    color: #999;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.draft-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 8px;
}

.draft-item:hover {
    background: #f0f0f0;
}

.draft-info {
    flex: 1;
}

.draft-name {
    font-weight: 500;
    color: #333;
}

.draft-date {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}

.draft-address {
    font-size: 0.85rem;
    color: #666;
    margin-top: 2px;
}

.draft-actions {
    display: flex;
    gap: 8px;
}

.btn-load-draft {
    background: #4caf50;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-load-draft:hover {
    background: #43a047;
}

.btn-delete-draft {
    background: #f44336;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-delete-draft:hover {
    background: #d32f2f;
}

/* Section Navigation */
.section-nav {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-top: none;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.section-nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.section-nav-links .nav-label {
    font-weight: 500;
    color: #666;
    margin-right: 5px;
}

.section-nav-links a {
    color: #1976d2;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #e3f2fd;
    transition: background 0.2s, color 0.2s;
}

.section-nav-links a:hover {
    background: #1976d2;
    color: white;
}

.section-nav-actions {
    display: flex;
    gap: 8px;
}

.btn-collapse-all,
.btn-expand-all {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    background: #f5f5f5;
    color: #555;
    transition: background 0.2s;
}

.btn-collapse-all:hover,
.btn-expand-all:hover {
    background: #e0e0e0;
}

/* Form Sections */
.form-section {
    background: white;
    margin-bottom: 2px;
    border: 1px solid #e0e0e0;
}

.form-section:last-of-type {
    border-radius: 0 0 8px 8px;
}

.section-header {
    background: #4caf50;
    color: white;
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 500;
    user-select: none;
    transition: background-color 0.2s;
}

.section-header:hover {
    background: #43a047;
}

.required-label {
    font-size: 0.75rem;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 3px;
    margin-left: 10px;
}

.toggle-icon {
    font-weight: bold;
    font-size: 1.2rem;
}

.section-content {
    padding: 20px;
    display: block;
}

.section-content.collapsed {
    display: none;
}

/* Form Layout */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group.flex-2 {
    flex: 2;
    min-width: 300px;
}

.form-group.full-width {
    flex: 100%;
    min-width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
    font-size: 0.9rem;
}

.form-group label small {
    font-weight: normal;
    color: #888;
}

/* Form Inputs */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

input:invalid:not(:placeholder-shown) {
    border-color: #f44336;
}

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

/* Checkbox and Radio Groups */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-group.inline {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 15px;
}

.checkbox-group label,
.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.9rem;
}

.checkbox-group input[type="radio"],
.checkbox-group input[type="checkbox"],
.checkbox-grid input[type="radio"],
.checkbox-grid input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #4caf50;
    cursor: pointer;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

/* Fieldset */
fieldset {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 20px;
    margin-top: 15px;
}

fieldset legend {
    padding: 0 10px;
    font-weight: 600;
    color: #666;
}

.attached-only {
    background: #fafafa;
}

/* Room Count Table */
.room-count-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.room-count-table th,
.room-count-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
}

.room-count-table th {
    background: #f5f5f5;
    font-weight: 500;
}

.room-count-table input {
    width: 60px;
    text-align: center;
}

/* Additional Rooms */
.room-entry {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
}

.room-entry h4 {
    margin-bottom: 10px;
    color: #666;
    font-size: 0.95rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    padding: 20px;
    background: white;
    border-radius: 0 0 8px 8px;
    border: 1px solid #e0e0e0;
    border-top: none;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #4caf50;
    color: white;
}

.btn-primary:hover {
    background: #43a047;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-secondary {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e8e8e8;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: #333;
}

#modalMessage {
    text-align: center;
}

#modalMessage.success {
    color: #2e7d32;
}

#modalMessage.error {
    color: #c62828;
}

#modalMessage h3 {
    margin-bottom: 10px;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4caf50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group {
        min-width: 100%;
    }

    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    .form-actions,
    .toggle-icon {
        display: none;
    }

    .section-content.collapsed {
        display: block;
    }
}
