/* ==========================================================================
   Digital Profiles — Single stylesheet
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-text: #2c2c2c;
    --color-accent: #3a3a3a;
    --color-accent-hover: #222;
    --color-bg: #f5f5f4;
    --color-card: #ffffff;
    --color-border: #e2e0dc;
    --color-muted: #7a7774;
    --color-success: #4a7c59;
    --color-success-bg: #eef4ef;
    --color-error: #8b4049;
    --color-error-bg: #f8eeef;
    --color-danger: #8b4049;
    --color-danger-hover: #6e3339;
    --color-donate: #4a4a4a;
    --color-donate-hover: #333;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
}

/* Card container */
.card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 540px;
    padding: 2rem;
}

.card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.flash-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.flash-error {
    background: var(--color-error-bg);
    color: var(--color-error);
}

/* Forms */
label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--color-text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-card);
    transition: border-color 0.2s;
    margin-bottom: 1rem;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(58, 58, 58, 0.08);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

button,
.btn {
    display: inline-block;
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.2s, opacity 0.2s;
}

button,
.btn-primary {
    background: var(--color-accent);
    color: #fff;
}

button:hover,
.btn-primary:hover {
    background: var(--color-accent-hover);
}

.btn-secondary {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--color-danger-hover);
}

.btn-small {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Profile page */
.profile-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.profile-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.profile-title {
    color: var(--color-text);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.profile-tagline {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.profile-bio {
    color: var(--color-text);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.7;
    white-space: pre-line;
}

.profile-section {
    margin-bottom: 1.25rem;
}

.profile-section h2 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.profile-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    gap: 0.75rem;
}

.profile-item:last-child {
    border-bottom: none;
}

.profile-item-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
    min-width: 60px;
}

.profile-item a {
    color: var(--color-text);
    text-decoration: underline;
    text-decoration-color: var(--color-border);
    text-underline-offset: 2px;
    word-break: break-all;
}

.profile-item a:hover {
    text-decoration-color: var(--color-text);
}

/* Profile photo (public page) */
.profile-photo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.profile-photo {
    width: 120px;
    height: 120px;
    max-width: 120px;
    max-height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--color-border);
}

/* Non-profit badge (public page) */
.profile-nonprofit-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.75rem;
    background: #f0efed;
    border-radius: 999px;
}

.nonprofit-badge-logo {
    width: 22px;
    height: 22px;
    max-width: 22px;
    max-height: 22px;
    border-radius: 4px;
    object-fit: contain;
}

.nonprofit-badge-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text);
}

/* Non-profit description */
.nonprofit-description {
    font-size: 0.95rem;
    color: var(--color-text);
    line-height: 1.6;
    margin-bottom: 0.75rem;
    white-space: pre-line;
}

/* Donate button */
.profile-donate {
    margin-top: 1.5rem;
}

.btn-donate {
    background: var(--color-donate);
    color: #fff;
}

.btn-donate:hover {
    background: var(--color-donate-hover);
}

/* Upload previews (edit page) */
.upload-preview {
    margin-bottom: 0.5rem;
}

.preview-photo {
    width: 80px;
    height: 80px;
    max-width: 80px;
    max-height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
    display: block;
    margin-bottom: 0.5rem;
}

.preview-logo {
    width: 60px;
    height: 60px;
    max-width: 60px;
    max-height: 60px;
    border-radius: var(--radius);
    object-fit: contain;
    border: 1px solid var(--color-border);
    display: block;
    margin-bottom: 0.5rem;
}

.upload-remove {
    font-size: 0.85rem;
    color: var(--color-danger);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.save-contact {
    margin-top: 0.75rem;
}

.save-contact .btn {
    background: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-border);
}

.save-contact .btn:hover {
    background: var(--color-bg);
}

/* Repeating field groups (edit page) */
.field-group {
    margin-bottom: 1.5rem;
}

.field-group h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.field-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.field-row input {
    margin-bottom: 0;
}

.field-row .field-label-input {
    flex: 0 0 30%;
}

.field-row .field-value-input {
    flex: 1;
}

.field-row .btn-remove {
    flex: 0 0 auto;
    padding: 0.6rem 0.75rem;
    background: none;
    color: var(--color-danger);
    border: 1px solid var(--color-border);
    font-size: 1rem;
    line-height: 1;
}

.field-row .btn-remove:hover {
    background: var(--color-error-bg);
}

.btn-add {
    background: none;
    color: var(--color-muted);
    border: 1px dashed var(--color-border);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.btn-add:hover {
    background: rgba(0, 0, 0, 0.02);
    color: var(--color-text);
}

/* Nav bar (for logged-in pages) */
.nav {
    width: 100%;
    max-width: 540px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

.nav a {
    color: var(--color-accent);
    text-decoration: none;
}

.nav a:hover {
    text-decoration: underline;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

/* Admin table */
.table-wrap {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-muted);
}

/* 404 page */
.not-found {
    text-align: center;
    padding: 3rem 1rem;
}

.not-found h1 {
    font-size: 3rem;
    color: var(--color-border);
    margin-bottom: 0.5rem;
}

.not-found p {
    color: var(--color-muted);
}

/* Utilities */
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.text-muted { color: var(--color-muted); }
.text-small { font-size: 0.85rem; }
.text-center { text-align: center; }

hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 1.5rem 0;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 1rem 0.75rem;
    }

    .card {
        padding: 1.5rem;
    }

    .profile-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
    }

    .profile-item a {
        font-size: 0.875rem;
    }

    .field-row {
        flex-wrap: wrap;
    }

    .field-row .field-label-input {
        flex: 1 1 100%;
    }

    .field-row .field-value-input {
        flex: 1;
    }
}
