/* ================================================
   Neal & McDevitt Matter Intake System
   Main Stylesheet
   ================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #e8e4e0;
    color: #2c2c2c;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 16px;
}

/* --- Logo & Header --- */
.site-header {
    width: 100%;
    max-width: 720px;
    text-align: center;
    margin-bottom: 24px;
}

.site-header img {
    max-width: 220px;
    height: auto;
}

/* --- Main Card --- */
.form-card {
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.10);
    width: 100%;
    max-width: 720px;
    padding: 36px 40px;
    margin-bottom: 30px;
}

/* --- Form Title Bar --- */
.form-title-bar {
    background-color: #dcd8d5;
    border-radius: 4px 4px 0 0;
    padding: 14px 20px;
    margin: -36px -40px 28px -40px;
    text-align: center;
}

.form-title-bar h1 {
    font-family: 'Arial Black', 'Arial Bold', Arial, sans-serif;
    font-size: 16px;
    font-weight: 900;
    color: #2c2c2c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2c2c2c;
    margin-bottom: 8px;
}

.form-group label .required {
    color: #c0392b;
    margin-left: 3px;
}

.form-group .field-hint {
    font-size: 12px;
    color: #666666;
    margin-top: 4px;
    font-style: italic;
}

.form-group .field-description {
    font-size: 13px;
    color: #555555;
    margin-bottom: 8px;
    padding: 8px 12px;
    background-color: #f8f6f4;
    border-left: 3px solid #9b8c7e;
    border-radius: 0 3px 3px 0;
}

/* --- Text Inputs --- */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #c8c0b8;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    color: #2c2c2c;
    background-color: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #9b8c7e;
    box-shadow: 0 0 0 3px rgba(155, 140, 126, 0.15);
}

input[type="text"].error,
input[type="email"].error,
select.error,
textarea.error {
    border-color: #c0392b;
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.10);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

/* --- Radio Buttons --- */
.radio-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.radio-group.single-column {
    grid-template-columns: 1fr;
}

.radio-group.three-column {
    grid-template-columns: repeat(3, 1fr);
}

.radio-option {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border: 1px solid #c8c0b8;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #ffffff;
}

.radio-option:hover {
    border-color: #9b8c7e;
    background-color: #f8f6f4;
}

.radio-option input[type="radio"] {
    width: auto;
    margin-right: 10px;
    accent-color: #9b8c7e;
    cursor: pointer;
    flex-shrink: 0;
}

.radio-option.selected {
    border-color: #9b8c7e;
    background-color: #f0ece8;
}

.radio-option span {
    font-size: 14px;
    color: #2c2c2c;
    line-height: 1.3;
}

/* --- Yes/No Toggle --- */
.yes-no-group {
    display: flex;
    gap: 12px;
}

.yes-no-group .radio-option {
    flex: 1;
    justify-content: center;
}

/* --- AJAX Client Lookup --- */
.client-lookup-wrapper {
    position: relative;
}

.ajax-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #c8c0b8;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.10);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.ajax-suggestions.active {
    display: block;
}

.ajax-suggestion-item {
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f0ece8;
}

.ajax-suggestion-item:last-child {
    border-bottom: none;
}

.ajax-suggestion-item:hover,
.ajax-suggestion-item.highlighted {
    background-color: #f0ece8;
}

.ajax-loading {
    padding: 10px 14px;
    font-size: 13px;
    color: #888888;
    font-style: italic;
}

/* --- File Upload --- */
.file-upload-wrapper {
    border: 2px dashed #c8c0b8;
    border-radius: 4px;
    padding: 24px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    background-color: #faf9f7;
}

.file-upload-wrapper:hover,
.file-upload-wrapper.dragover {
    border-color: #9b8c7e;
    background-color: #f0ece8;
}

.file-upload-wrapper input[type="file"] {
    display: none;
}

.file-upload-wrapper .upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
    color: #9b8c7e;
}

.file-upload-wrapper .upload-text {
    font-size: 14px;
    color: #666666;
}

.file-upload-wrapper .upload-text strong {
    color: #9b8c7e;
    cursor: pointer;
}

.file-upload-wrapper .upload-hint {
    font-size: 12px;
    color: #999999;
    margin-top: 4px;
}

.file-preview {
    display: none;
    margin-top: 12px;
    padding: 10px;
    background-color: #f0ece8;
    border-radius: 4px;
    font-size: 13px;
    color: #2c2c2c;
}

.file-preview.active {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-preview img {
    max-height: 60px;
    max-width: 120px;
    object-fit: contain;
    border-radius: 3px;
}

.file-preview .file-name {
    flex: 1;
    word-break: break-all;
}

.file-preview .remove-file {
    color: #c0392b;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    letter-spacing: 0.3px;
}

.btn-primary {
    background-color: #3d4555;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #2c3340;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-secondary {
    background-color: #ffffff;
    color: #3d4555;
    border: 2px solid #3d4555;
}

.btn-secondary:hover {
    background-color: #f0ece8;
}

.btn-danger {
    background-color: #c0392b;
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #a93226;
}

.btn-success {
    background-color: #27ae60;
    color: #ffffff;
}

.btn-success:hover {
    background-color: #219a52;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* --- Form Navigation --- */
.form-nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e8e4e0;
    gap: 12px;
}

.form-nav.has-back {
    justify-content: space-between;
}

/* --- Progress Indicator --- */
.form-progress {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 28px;
}

.form-progress .step {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #c8c0b8;
    transition: background-color 0.3s ease;
}

.form-progress .step.active {
    background-color: #3d4555;
    width: 24px;
    border-radius: 4px;
}

.form-progress .step.completed {
    background-color: #9b8c7e;
}

/* --- Section Headers --- */
.section-header {
    background-color: #eeeeee;
    padding: 10px 14px;
    margin: 24px -40px 20px -40px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #434343;
}

/* --- Validation Messages --- */
.field-error {
    color: #c0392b;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.field-error.active {
    display: block;
}

.form-error-banner {
    background-color: #fdf0ee;
    border: 1px solid #e8b4ae;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 20px;
    color: #c0392b;
    font-size: 14px;
    display: none;
}

.form-error-banner.active {
    display: block;
}

/* --- Success / Confirmation Screen --- */
.confirmation-card {
    text-align: center;
    padding: 20px 0;
}

.confirmation-card .success-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.confirmation-card h2 {
    font-size: 22px;
    color: #2c2c2c;
    margin-bottom: 10px;
}

.confirmation-card p {
    font-size: 15px;
    color: #666666;
    margin-bottom: 28px;
}

.confirmation-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    margin: 0 auto;
}

/* --- Admin Portal --- */
.admin-nav {
    width: 100%;
    max-width: 960px;
    background-color: #3d4555;
    border-radius: 6px;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.admin-nav .nav-brand {
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
}

.admin-nav .nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.admin-nav .nav-links a {
    color: #c8c0b8;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.admin-nav .nav-links a:hover,
.admin-nav .nav-links a.active {
    color: #ffffff;
}

.admin-card {
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 960px;
    margin-bottom: 24px;
    overflow: hidden;
}

.admin-card-header {
    background-color: #dcd8d5;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-card-header h2 {
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #2c2c2c;
}

.admin-card-body {
    padding: 24px;
}

/* --- Status Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-pending {
    background-color: #fef3cd;
    color: #856404;
}

.badge-conflicts-sent {
    background-color: #d1ecf1;
    color: #0c5460;
}

.badge-closed {
    background-color: #d4edda;
    color: #155724;
}

/* --- Table Styles --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    background-color: #f8f6f4;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #434343;
    border-bottom: 2px solid #dcd8d5;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f0ece8;
    color: #2c2c2c;
    vertical-align: top;
}

.data-table tr:hover td {
    background-color: #faf9f7;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* --- Loading Spinner --- */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #c8c0b8;
    border-top-color: #3d4555;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* --- Multi-field Row --- */
.field-row {
    display: grid;
    gap: 16px;
}

.field-row.two-col {
    grid-template-columns: 1fr 1fr;
}

.field-row.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

/* --- Hidden Fields --- */
.hidden {
    display: none !important;
}

/* --- Footer --- */
.site-footer {
    width: 100%;
    max-width: 720px;
    text-align: center;
    font-size: 12px;
    color: #999999;
    padding: 16px 0;
}

/* ================================================
   Responsive / Mobile
   ================================================ */
@media (max-width: 640px) {
    body {
        padding: 16px 12px;
    }

    .form-card {
        padding: 24px 20px;
    }

    .form-title-bar {
        margin: -24px -20px 20px -20px;
        padding: 12px 16px;
    }

    .form-title-bar h1 {
        font-size: 14px;
    }

    .section-header {
        margin: 20px -20px 16px -20px;
    }

    .radio-group {
        grid-template-columns: 1fr;
    }

    .radio-group.three-column {
        grid-template-columns: 1fr;
    }

    .field-row.two-col,
    .field-row.three-col {
        grid-template-columns: 1fr;
    }

    .form-nav {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .form-nav .btn {
        width: 100%;
    }

    .admin-nav .nav-links {
        gap: 12px;
    }

    .confirmation-actions {
        width: 100%;
    }

    .yes-no-group {
        gap: 8px;
    }
}

@media (max-width: 400px) {
    .site-header img {
        max-width: 160px;
    }

    .form-card {
        padding: 20px 16px;
    }
}