﻿/* Organization CRUD Functionality Styles */

/* Section Edit Buttons */
.section-title {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.btn-section-edit,
.btn-section-add {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
    flex-shrink: 0;
}

.btn-section-edit:hover,
.btn-section-add:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #1d4ed8;
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

.btn-section-add {
    background: rgba(34, 197, 94, 0.1);
    color: #059669;
    border-color: rgba(34, 197, 94, 0.3);
}

.btn-section-add:hover {
    background: rgba(34, 197, 94, 0.2);
    color: #047857;
    border-color: rgba(34, 197, 94, 0.5);
}

/* Contact Action Buttons */
.contact-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.contact-actions {
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
    flex-shrink: 0;
}

.btn-contact-edit,
.btn-contact-delete {
    background: none;
    border: 1px solid transparent;
    padding: 0.25rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.btn-contact-edit {
    color: #6b7280;
}

.btn-contact-edit:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
}

.btn-contact-delete {
    color: #6b7280;
}

.btn-contact-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Modal Styles */
.crud-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    backdrop-filter: blur(4px);
    padding: 20px;
    overflow-y: auto;
}

.crud-modal.show {
    display: flex;
}

.crud-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.crud-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.3s ease;
    margin: auto;
}

.crud-modal.show .crud-modal-content {
    transform: translateY(0) scale(1);
}

.crud-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.crud-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.crud-modal-close {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.crud-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.crud-modal-body {
    padding: 2rem;
    max-height: calc(90vh - 160px);
    overflow-y: auto;
}

.crud-modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.5rem 2rem;
    border-top: 1px solid #e5e7eb;
    background: #f8f9fa;
}

/* Form Styles */
.crud-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group.required label::after {
    content: " *";
    color: #dc3545;
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #374151;
    display: block;
}

.form-control {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-text {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.text-danger {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

/* Checkbox and Toggle Styles */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-check-input {
    margin: 0;
    transform: scale(1.1);
    accent-color: #3b82f6;
}

.form-check-label {
    margin: 0;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Alert Styles */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-danger {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.alert-success {
    background-color: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.alert-info {
    background-color: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.alert h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.alert ul {
    margin: 0;
    padding-left: 1.25rem;
}

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    justify-content: center;
    font-size: 0.9rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
    color: white;
    text-decoration: none;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
    transform: translateY(-1px);
    color: white;
    text-decoration: none;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
    color: white;
    text-decoration: none;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
    color: white;
    text-decoration: none;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Services Modal Styles */
.services-grid-modal {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.service-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.service-option:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.service-option.selected {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.service-option input[type="checkbox"] {
    margin: 0;
    transform: scale(1.1);
    accent-color: #3b82f6;
}

.service-info {
    flex: 1;
    min-width: 0;
}

.service-name-modal {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.service-description-modal {
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.4;
}

/* No Content Messages */
.no-contacts-message,
.no-services-message {
    text-align: center;
    padding: 2rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.no-contacts-message p,
.no-services-message p {
    margin: 0 0 1rem 0;
    color: #6b7280;
    font-style: italic;
}

/* Delete Modal Specific Styles */
.delete-warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.delete-warning-icon {
    color: #ef4444;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

.delete-warning-text {
    color: #b91c1c;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.delete-warning-details {
    color: #7f1d1d;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* County selection enhancements */
#edit-county-selection-container .btn-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: linear-gradient(135deg, #eef2ff 0%, #e0f2fe 100%);
    color: #1f2937;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.12);
}

#edit-county-selection-container .btn-toggle.active,
#edit-county-selection-container .btn-toggle:hover {
    border-color: #3b82f6;
    color: #1d4ed8;
    box-shadow: 0 6px 14px rgba(59, 130, 246, 0.2);
}

#edit-selected-counties-display {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.6rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.selected-items-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: #374151;
}

#edit-selected-counties-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

#edit-selected-counties-tags .tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    background: #e0f2fe;
    color: #0f172a;
    border: 1px solid #bae6fd;
    border-radius: 999px;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(14, 165, 233, 0.12);
}

#edit-selected-counties-tags .tag button {
    border: none;
    background: transparent;
    color: #0ea5e9;
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    padding: 0 0.15rem;
}

#edit-county-checkboxes {
    margin-top: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    padding: 0.75rem;
    max-height: 240px;
    overflow: hidden;
}

#edit-county-checkboxes .checkbox-group-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.25rem 0.35rem 0.5rem;
    border-bottom: 1px dashed #e5e7eb;
    margin-bottom: 0.65rem;
}

#edit-county-checkboxes .checkbox-group-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.35rem 0.5rem;
    max-height: 180px;
    padding: 0.35rem 0.75rem 0.5rem 0.75rem;
    overflow-y: auto;
    overflow-x: visible;
    padding-left: 1rem;
}

/* Fix county list clipping inside modal */
#edit-county-checkboxes .checkbox-group-list .form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.4rem;
}

#edit-county-checkboxes .checkbox-group-list .form-check-label {
    display: inline-block;
    line-height: 1.3;
}

#edit-county-checkboxes .checkbox-group-list .form-check:hover {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

#edit-county-toggle {
    font-size: 0.92rem;
}

.selected-items-header .btn-link,
.checkbox-group-toolbar .btn-link {
    font-size: 0.9rem;
    color: #1d4ed8;
}

@media (max-width: 768px) {
    .crud-modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
    }

    .crud-modal-header,
    .crud-modal-body,
    .crud-modal-footer {
        padding: 1rem;
    }

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

    .services-grid-modal {
        grid-template-columns: 1fr;
    }

    .contact-name {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .contact-actions {
        margin-left: 0;
    }

    .section-title {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .btn-section-edit,
    .btn-section-add {
        margin-left: 0;
        align-self: flex-end;
    }

    #edit-county-checkboxes .checkbox-group-list {
        grid-template-columns: 1fr;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .crud-modal-content {
        border: 2px solid #000;
    }

    .btn-section-edit,
    .btn-section-add {
        border: 2px solid currentColor;
    }

    .service-option {
        border: 2px solid #000;
    }

    .service-option.selected {
        background: #000;
        color: #fff;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .crud-modal-content,
    .btn,
    .btn-section-edit,
    .btn-section-add,
    .service-option {
        transition: none;
    }

    .crud-modal.show .crud-modal-content {
        transform: none;
    }

    .spinner {
        animation: none;
    }
}

/* Restore scrolling for county list */
#edit-county-checkboxes .checkbox-group-list {
    max-height: 180px;
    overflow-y: auto;
    overflow-x: visible;
}

/* Optional: smooth scrollbar */
#edit-county-checkboxes .checkbox-group-list::-webkit-scrollbar {
    width: 8px;
}
#edit-county-checkboxes .checkbox-group-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 6px;
}
#edit-county-checkboxes .checkbox-group-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Prevent left clipping on county checkboxes */
#edit-county-checkboxes .checkbox-group-list {
    padding-left: 2rem;
}
