/**
 * IslandBarter Exchange — Front-end styles.
 * Minimal CSS that inherits from the active theme's design system.
 * Uses CSS custom properties defined by the theme where available.
 *
 * @version 1.0.0
 */

/* ==========================================================================
   CSS Variables (fallbacks — theme overrides take priority)
   ========================================================================== */
:root {
    --ib-ocean: var(--ocean, #0c3b5e);
    --ib-coral: var(--coral, #e05a47);
    --ib-green: var(--green, #1d8a4e);
    --ib-yellow: var(--yellow, #e8a817);
    --ib-sand: var(--sand, #faf5ec);
    --ib-mist: var(--mist, #6b7f8e);
    --ib-font-display: var(--font-display, 'Fraunces', serif);
    --ib-font-body: var(--font-body, 'DM Sans', sans-serif);
    --ib-radius: 8px;
    --ib-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --ib-shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Notices
   ========================================================================== */
.ib-notice {
    padding: 1rem 1.25rem;
    border-radius: var(--ib-radius);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}
.ib-notice ul { margin: 0.5rem 0 0 1.25rem; padding: 0; }
.ib-notice--success { background: #ecfdf5; border-left: 4px solid var(--ib-green); color: #065f46; }
.ib-notice--error   { background: #fef2f2; border-left: 4px solid var(--ib-coral); color: #991b1b; }
.ib-notice--warning { background: #fffbeb; border-left: 4px solid var(--ib-yellow); color: #92400e; }
.ib-notice--info    { background: #eff6ff; border-left: 4px solid var(--ib-ocean); color: #1e3a5f; }

/* ==========================================================================
   Dashboard Layout
   ========================================================================== */
.ib-dashboard {
    max-width: 1100px;
    margin: 0 auto;
    font-family: var(--ib-font-body);
}

.ib-dashboard-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ib-tab {
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    color: var(--ib-mist);
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}
.ib-tab:hover { color: var(--ib-ocean); }
.ib-tab.ib-tab-active {
    color: var(--ib-ocean);
    border-bottom-color: var(--ib-ocean);
}

.ib-badge {
    display: inline-block;
    background: var(--ib-coral);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    vertical-align: middle;
    margin-left: 0.25rem;
}

/* ==========================================================================
   Stats Grid
   ========================================================================== */
.ib-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ib-stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--ib-radius);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--ib-shadow);
}
.ib-stat-label {
    font-size: 0.8rem;
    color: var(--ib-mist);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
}
.ib-stat-value {
    font-family: var(--ib-font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ib-ocean);
}
.ib-balance { color: var(--ib-green); }

/* ==========================================================================
   Sections
   ========================================================================== */
.ib-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--ib-radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--ib-shadow);
}
.ib-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.ib-section-header h3 {
    margin: 0;
    font-family: var(--ib-font-display);
    font-size: 1.15rem;
    color: var(--ib-ocean);
}
.ib-section-header h4 {
    margin: 0;
    font-size: 1rem;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.ib-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.ib-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ib-mist);
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}
.ib-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.ib-table tr:last-child td { border-bottom: none; }
.ib-table code {
    font-size: 0.8rem;
    background: #f3f4f6;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.ib-info-table { width: 100%; font-size: 0.9rem; }
.ib-info-table td { padding: 0.4rem 0; }
.ib-info-table td:first-child { font-weight: 600; color: var(--ib-mist); width: 160px; }

.ib-amount-debit  { color: var(--ib-coral); font-weight: 600; }
.ib-amount-credit { color: var(--ib-green); font-weight: 600; }

/* ==========================================================================
   Status Badges
   ========================================================================== */
.ib-status {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ib-status--active,
.ib-status--completed { background: #ecfdf5; color: #065f46; }
.ib-status--pending   { background: #fffbeb; color: #92400e; }
.ib-status--suspended,
.ib-status--disputed  { background: #fef2f2; color: #991b1b; }
.ib-status--cancelled,
.ib-status--reversed  { background: #f3f4f6; color: #6b7280; }
.ib-status--paused    { background: #eff6ff; color: #1e40af; }
.ib-status--sold      { background: #f0fdf4; color: #166534; }
.ib-status--expired   { background: #f3f4f6; color: #6b7280; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.ib-btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--ib-radius);
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s, transform 0.1s;
    line-height: 1.3;
    text-align: center;
    font-family: var(--ib-font-body);
}
.ib-btn:hover { opacity: 0.9; }
.ib-btn:active { transform: scale(0.98); }

.ib-btn--primary {
    background: var(--ib-ocean);
    color: #fff;
}
.ib-btn--primary:hover { color: #fff; }
.ib-btn--danger {
    background: var(--ib-coral);
    color: #fff;
}
.ib-btn--sm {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
}
.ib-btn:disabled,
.ib-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.ib-link {
    color: var(--ib-ocean);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}
.ib-link:hover { text-decoration: underline; }

.ib-muted { color: var(--ib-mist); font-size: 0.8rem; }
.ib-empty { color: var(--ib-mist); font-style: italic; text-align: center; padding: 2rem 1rem; }

/* ==========================================================================
   Filters
   ========================================================================== */
.ib-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.ib-filter-btn {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    border-radius: var(--ib-radius);
    text-decoration: none;
    color: var(--ib-mist);
    background: #f3f4f6;
    font-weight: 500;
    transition: background 0.15s;
}
.ib-filter-btn:hover,
.ib-filter-btn.active {
    background: var(--ib-ocean);
    color: #fff;
}

/* ==========================================================================
   Pagination
   ========================================================================== */
.ib-pagination {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
    margin-top: 1.25rem;
}
.ib-pagination a {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    border-radius: var(--ib-radius);
    text-decoration: none;
    font-size: 0.85rem;
    color: var(--ib-ocean);
    background: #f3f4f6;
}
.ib-pagination a.active,
.ib-pagination a:hover {
    background: var(--ib-ocean);
    color: #fff;
}

/* ==========================================================================
   Forms
   ========================================================================== */
.ib-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.3rem;
}
.ib-form label .required { color: var(--ib-coral); }

.ib-form input[type="text"],
.ib-form input[type="email"],
.ib-form input[type="tel"],
.ib-form input[type="password"],
.ib-form input[type="number"],
.ib-form textarea,
.ib-form select {
    display: block;
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    font-family: var(--ib-font-body);
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.ib-form input:focus,
.ib-form textarea:focus,
.ib-form select:focus {
    outline: none;
    border-color: var(--ib-ocean);
    box-shadow: 0 0 0 3px rgba(12, 59, 94, 0.1);
}

.ib-form small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--ib-mist);
}

.ib-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.ib-form-field {
    margin-bottom: 1rem;
}

.ib-form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
    align-items: center;
}

.ib-form-note {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--ib-mist);
}

.ib-form h3 {
    font-family: var(--ib-font-display);
    color: var(--ib-ocean);
    font-size: 1.1rem;
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}
.ib-form h3:first-child { margin-top: 0; }

/* ==========================================================================
   Directory
   ========================================================================== */
.ib-directory {
    max-width: 1100px;
    margin: 0 auto;
    font-family: var(--ib-font-body);
}
.ib-directory-title {
    font-family: var(--ib-font-display);
    color: var(--ib-ocean);
    margin-bottom: 1rem;
}

.ib-directory-filters {
    margin-bottom: 1.25rem;
}
.ib-filter-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}
.ib-search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}
.ib-search-input:focus {
    outline: none;
    border-color: var(--ib-ocean);
}
.ib-filter-row select {
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
}

.ib-directory-count {
    font-size: 0.85rem;
    color: var(--ib-mist);
    margin-bottom: 1rem;
}

.ib-directory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.ib-member-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--ib-radius);
    padding: 1.25rem;
    box-shadow: var(--ib-shadow);
    transition: box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.ib-member-card:hover { box-shadow: var(--ib-shadow-lg); }

.ib-member-card-header {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}
.ib-member-card-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}
.ib-member-card-name {
    margin: 0;
    font-family: var(--ib-font-display);
    font-size: 1rem;
    color: var(--ib-ocean);
    line-height: 1.3;
}
.ib-member-card-category {
    font-size: 0.8rem;
    color: var(--ib-mist);
}
.ib-member-card-desc {
    font-size: 0.85rem;
    color: #4b5563;
    line-height: 1.5;
    flex-grow: 1;
    margin: 0 0 0.75rem;
}
.ib-member-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid #f3f4f6;
}
.ib-member-card-island {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ib-green);
}

/* ==========================================================================
   Messages
   ========================================================================== */
.ib-message-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.ib-message-item {
    display: block;
    padding: 0.9rem 1rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}
.ib-message-item:hover { background: #fafafa; }
.ib-message-item.ib-message-unread { background: #eff6ff; }
.ib-message-item.ib-message-unread:hover { background: #e0edff; }

.ib-message-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}
.ib-message-from { font-weight: 600; color: #374151; }
.ib-message-date { color: var(--ib-mist); }
.ib-message-subject { font-weight: 500; color: var(--ib-ocean); margin-bottom: 0.15rem; }
.ib-message-preview { font-size: 0.85rem; color: #6b7280; }

.ib-message-detail { margin-bottom: 1rem; }
.ib-message-detail-meta {
    font-size: 0.85rem;
    color: var(--ib-mist);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 1rem;
}
.ib-message-detail-body {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #374151;
}

/* ==========================================================================
   Registration form
   ========================================================================== */
.ib-registration-form {
    max-width: 700px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--ib-radius);
    padding: 2rem;
    box-shadow: var(--ib-shadow);
}

/* ==========================================================================
   AJAX Loading State
   ========================================================================== */
.ib-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}
.ib-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--ib-ocean);
    border-radius: 50%;
    animation: ib-spin 0.6s linear infinite;
}
@keyframes ib-spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    .ib-form-row { grid-template-columns: 1fr; }
    .ib-dashboard-nav { gap: 0; }
    .ib-tab { padding: 0.6rem 0.8rem; font-size: 0.8rem; }
    .ib-table { font-size: 0.8rem; }
    .ib-table th, .ib-table td { padding: 0.4rem 0.5rem; }
    .ib-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .ib-directory-grid { grid-template-columns: 1fr; }
    .ib-filter-row { flex-direction: column; }
    .ib-filter-row select,
    .ib-search-input { width: 100%; min-width: unset; }
    .ib-registration-form { padding: 1.25rem; }
}
