/* Base Layout & Typography */
body {
    font-family: system-ui, -apple-system, sans-serif;
    max-width: 1150px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    line-height: 1.5;
    color: #222;
    background: #f8f9fa;
}

body.form-page {
    max-width: 800px;
    background: #fff;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

header h1 {
    margin: 0;
}

.subtitle {
    color: #666;
}

/* Alerts */
.alert {
    padding: 0.9rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
}

.alert-success {
    background: #e6f4ea;
    color: #137333;
    border: 1px solid #ceead6;
}

.alert-error {
    background: #fce8e6;
    color: #c5221f;
    border: 1px solid #fad2cf;
}

/* Buttons */
.btn-primary {
    background: #1a73e8;
    color: #fff;
    text-decoration: none;
    border: none;
    padding: 0.65rem 1.25rem;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: inline-block;
}

.btn-primary:hover {
    background: #1557b0;
}

.btn-ai {
    background: #673ab7;
    color: #fff;
    text-decoration: none;
    display: inline-block;
    border: none;
    padding: 0.65rem 1.25rem;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-ai:hover {
    background: #512da8;
}

.btn-ai:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    text-decoration: none;
    color: #222;
    display: inline-block;
}

.btn-sm:hover {
    background: #f1f3f4;
}

.btn-match {
    background: #e8f0fe;
    border-color: #1967d2;
    color: #1967d2;
    font-weight: 600;
}

.btn-reunite {
    background: #137333;
    color: #fff;
    border-color: #137333;
}

.btn-reunite:hover {
    background: #0d5626;
}

/* Dashboard Stats & Filters */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    text-align: center;
}

.stat-box strong {
    display: block;
    font-size: 1.75rem;
}

.stat-lost { color: #c5221f; }
.stat-found { color: #1967d2; }
.stat-reunited { color: #137333; }

.filters {
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.filters select,
.filters input {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
}

.filters button {
    padding: 0.5rem 1rem;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Dashboard Cards */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 1.25rem;
}

.card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-img {
    width: 100%;
    height: 210px;
    object-fit: cover;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
}

.card-body {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.card-title {
    margin: 0.25rem 0;
}

.card-location {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.5rem;
}

.card-excerpt {
    font-size: 0.9rem;
    color: #333;
    margin: 0.5rem 0 1rem;
}

.card-actions {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid #eee;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.inline-form {
    margin: 0;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-lost {
    background: #fce8e6;
    color: #c5221f;
}

.badge-found {
    background: #e8f0fe;
    color: #1967d2;
}

.badge-reunited,
.badge-score {
    background: #e6f4ea;
    color: #137333;
}

/* Match Panels & Cards */
.match-panel {
    background: #fff;
    border: 2px solid #1a73e8;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.match-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.match-panel-header h2 {
    margin: 0;
}

.match-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    border-top: 1px solid #eee;
    padding: 0.85rem 0;
}

.match-row img,
.match-card img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 6px;
}

.match-row-info {
    flex: 1;
}

.match-row-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.match-card {
    display: flex;
    gap: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fafafa;
}

/* Submission Form */
fieldset {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

legend {
    font-weight: 600;
    padding: 0 0.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.form-group {
    margin-top: 1rem;
}

label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="url"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1rem;
}

textarea {
    height: 110px;
    resize: vertical;
}

.ai-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding: 0.75rem;
    background: #f3e5f5;
    border-radius: 6px;
    gap: 1rem;
}

.ai-status {
    font-size: 0.85rem;
    color: #555;
}

.ai-status.success {
    color: #137333;
    font-weight: 500;
}

.ai-status.error {
    color: #c5221f;
    font-weight: 500;
}

.checkbox-group {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-top: 0.75rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: normal;
    cursor: pointer;
}

/* Edit Page Additions */
.header-actions {
    display: flex;
    gap: 0.5rem;
}

.current-photo-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.edit-preview-img {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 6px;
}

.remove-photo-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #c5221f;
    cursor: pointer;
}

.danger-zone {
    margin-top: 2.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid #fad2cf;
    background: #fce8e6;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    color: #c5221f;
    font-size: 0.9rem;
}

.btn-danger {
    background: #c5221f;
    color: #fff;
    border: none;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-danger:hover {
    background: #a50e0e;
}

/* Distinct 3-Option Image Selector */
.photo-methods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
    margin-top: 0.4rem;
}

.photo-method-card {
    border: 1px solid #cfd8dc;
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.photo-method-card p {
    font-size: 0.82rem;
    color: #546e7a;
    margin: 0.35rem 0 0.65rem;
    line-height: 1.4;
}

.photo-method-card input[type="file"] {
    font-size: 0.85rem;
}

.method-badge {
    display: inline-block;
    align-self: flex-start;
    background: #e3f2fd;
    color: #1565c0;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.4rem;
}

.paste-zone {
    border: 2px dashed #90caf9;
    cursor: pointer;
}

.paste-zone:hover,
.paste-zone:focus {
    border-color: #1a73e8;
    background: #eef5fd;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
    outline: none;
}

/* Required Fields Highlighted in Blue */
label.required-label {
    color: #1565c0;
    font-weight: 600;
}

input:required,
select:required,
textarea:required {
    border-color: #64b5f6;
    border-left: 4px solid #1a73e8;
    background-color: #f8fbff;
}

input:required:focus,
select:required:focus,
textarea:required:focus {
    border-color: #1a73e8;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
    outline: none;
}

/* Post Link Button */
.btn-source {
    background: #1a73e8;
    border-color: #1a73e8;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
}

.btn-fb:hover {
    background: #145dbf;
    color: #fff;
}

.url-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.url-input-group input {
    flex: 1;
}

/* Source Platform Tag Badges */
.badge-platform {
    background: #eceff1;
    color: #37474f;
    margin-left: 0.25rem;
}

.platform-facebook   { background: #e7f3ff; color: #1877f2; }
.platform-nextdoor   { background: #e8f5e9; color: #2e7d32; }
.platform-pawboost   { background: #fff3e0; color: #ef6c00; }
.platform-ring       { background: #e0f7fa; color: #00838f; }
.platform-craigslist { background: #f3e5f5; color: #6a1b9a; }
.platform-shelter    { background: #fce4ec; color: #ad1457; }

/* Full-Database Scan Pair Comparison */
.pair-card {
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    background: #fcfdfe;
}

.pair-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.pair-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.pair-side {
    display: flex;
    gap: 0.85rem;
    padding: 0.75rem;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e0e0e0;
}

.pair-lost {
    border-left: 4px solid #c5221f;
}

.pair-found {
    border-left: 4px solid #1967d2;
}

.pair-side img {
    width: 95px;
    height: 95px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.pair-side h4 {
    margin: 0.35rem 0 0.25rem;
}

.pair-links {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

/* Paste Zone & Image Preview */
.paste-zone {
    border: 2px dashed #b0bec5;
    background: #f8fafc;
    border-radius: 6px;
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    color: #455a64;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.paste-zone:focus,
.paste-zone:hover {
    border-color: #1a73e8;
    background: #eef5fd;
    outline: none;
}

.photo-preview-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #f1f8e9;
    border: 1px solid #c5e1a5;
    border-radius: 6px;
}

.photo-preview-box img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ccc;
}

/* AI Photo Comparison Button & Verdict Box */
.btn-ai-compare {
    background: #f3e5f5;
    border-color: #8e24aa;
    color: #6a1b9a;
    font-weight: 600;
}

.btn-ai-compare:hover {
    background: #e1bee7;
}

.ai-compare-result {
    margin-top: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    border: 1px solid #cfd8dc;
    background: #f8fafc;
}

.ai-compare-result.verdict-high {
    background: #e6f4ea;
    border-color: #81c784;
    color: #1b5e20;
}

.ai-compare-result.verdict-mid {
    background: #fff8e1;
    border-color: #ffd54f;
    color: #7f6000;
}

.ai-compare-result.verdict-low {
    background: #fce8e6;
    border-color: #e57373;
    color: #b71c1c;
}

.ai-feature-list {
    margin: 0.35rem 0 0;
    padding-left: 1.1rem;
    list-style: none;
}

.ai-feature-list li {
    margin-bottom: 0.2rem;
}
