﻿/* ============================================================
   components.css
   ------------------------------------------------------------
   Reusable UI primitives: buttons, icon buttons, form fields,
   inputs, flash messages, avatars, role/state badges, chips,
   panel blocks, tables, key/value grid, empty states,
   profile preview, admin filter form, invite panel.
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    line-height: 1.2;
}
.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary { background: var(--orange); color: white; }
.btn-primary:hover { background: #CC5500; color: white; text-decoration: none; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--navy);
}
.btn-ghost:hover { background: var(--gray-100); text-decoration: none; }

.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #16A34A; }

.btn-danger-soft {
    background: #FEF2F2;
    color: var(--red);
    border: 1px solid #FECACA;
}
.btn-danger-soft:hover {
    background: #FEE2E2;
    color: var(--red);
    text-decoration: none;
}

.btn-lg   { padding: 13px 28px; font-size: 1rem; }
.btn-sm   { padding: 6px 14px;  font-size: 0.82rem; }
.btn-block { width: 100%; }

/* ---------- Icon buttons ---------- */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
    flex-shrink: 0;
}
.icon-btn:hover {
    background: var(--gray-100);
    color: var(--navy);
    text-decoration: none;
}
.icon-btn-danger:hover { background: #FEF2F2; color: var(--red); }
.icon-btn-accent { color: white; background: var(--orange); }
.icon-btn-accent:hover { background: #CC5500; color: white; }

/* ---------- Mini buttons (in-table) ---------- */
.mini-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--navy);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
    font-family: inherit;
}
.mini-btn:hover { background: var(--gray-100); }

.mini-danger {
    color: var(--red);
    border-color: #FECACA;
    background: #FEF2F2;
}
.mini-danger:hover { background: #FEE2E2; }

.mini-select {
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.78rem;
    font-family: inherit;
    background: var(--white);
}

/* ---------- Form fields ---------- */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 6px;
}

.input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.92rem;
    font-family: inherit;
    transition: 0.15s;
    background: var(--white);
    color: var(--gray-800);
}
.input:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.12);
}

.input-compact {
    height: 30px;
    padding: 4px 10px;
    font-size: 0.82rem;
}
.input-select {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--gray-600) 50%),
        linear-gradient(135deg, var(--gray-600) 50%, transparent 50%);
    background-position:
        calc(100% - 14px) calc(50% - 2px),
        calc(100% - 9px)  calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 26px;
}

.err {
    display: block;
    color: var(--red);
    font-size: 0.78rem;
    margin-top: 4px;
}
.hint {
    display: block;
    font-size: 0.78rem;
    color: var(--gray-600);
    margin-top: 4px;
}
.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 16px;
}
.checkline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--orange);
}
.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 12px;
    flex-wrap: wrap;
}
.link-sm { font-size: 0.82rem; }

/* ---------- Flash messages ---------- */
.flash-wrap {
    max-width: 1400px;
    margin: 16px auto 0;
    padding: 0 24px;
    width: 100%;
}
.flash {
    padding: 12px 18px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    font-size: 0.9rem;
    border-left: 4px solid;
}
.flash-success { background: #F0FDF4; color: #166534; border-color: var(--green); }
.flash-danger  { background: #FEF2F2; color: #991B1B; border-color: var(--red); }
.flash-info    { background: #EFF6FF; color: #1E40AF; border-color: var(--blue); }
.flash-warning { background: #FFFBEB; color: #92400E; border-color: var(--yellow); }

/* ---------- Avatars ---------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--navy);
    color: white;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}
.avatar-sm { width: 30px; height: 30px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-lg .avatar-initials { font-size: 1.15rem; }

/* ---------- Role badges ---------- */
.role-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 12px;
}
.role-owner         { background: #FFF4EA; color: #9A3412; border: 1px solid #FED7AA; }
.role-contributor   { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.role-guest         { background: #EEF2F8; color: #475569; border: 1px solid #CBD5E1; }
.role-manager       { background: #F5F3FF; color: #5B21B6; border: 1px solid #DDD6FE; }
.role-administrator { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.role-user          { background: #EEF2F8; color: #475569; border: 1px solid #CBD5E1; }

.you-tag {
    font-size: 0.65rem;
    background: var(--gray-200);
    color: var(--gray-600);
    padding: 1px 7px;
    border-radius: 8px;
    margin-left: 6px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* ---------- State badges ---------- */
.state-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 12px;
}
.state-active    { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.state-inactive  { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.state-available { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.state-used      { background: #EEF2F8; color: #475569; border: 1px solid #CBD5E1; }
.state-expired   { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.state-info      { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

.row-inactive .member-name { color: var(--gray-600); }
.row-inactive .avatar { background: var(--gray-400); }

/* ---------- Generic chips ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}
.chip strong { font-weight: 800; }
.chip-all      { background: #EEF2F8; color: var(--navy); }
.chip-matched  { background: #EFF6FF; color: #1E40AF; }
.chip-approved { background: #F0FDF4; color: #166534; }
.chip-pending  { background: #FFFBEB; color: #92400E; }
.chip-filter {
    background: #FFF4EA;
    color: #9A3412;
    border: 1px solid #FED7AA;
}
.chip-filter .chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #FED7AA;
    color: #9A3412;
    font-weight: 700;
    font-size: 0.7rem;
    text-decoration: none;
    margin-left: 2px;
}
.chip-filter .chip-remove:hover { background: #FDBA74; }

/* ---------- Code chip (reference codes) ---------- */
.code-chip {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.82rem;
    letter-spacing: 0.5px;
    background: var(--gray-100);
    border: 1px dashed var(--gray-300);
    border-radius: 6px;
    padding: 3px 10px;
    color: var(--navy);
    cursor: text;
    user-select: all;
}

/* ---------- Panel block ---------- */
.panel-block {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 22px;
}
.panel-block-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.panel-block h2 {
    font-size: 1.15rem;
    color: var(--navy);
    letter-spacing: -0.3px;
}
.panel-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--gray-200);
    flex-wrap: wrap;
}
.muted-panel {
    background: var(--gray-100);
    border: 1px dashed var(--gray-300);
    box-shadow: none;
}
.muted-panel p {
    margin-top: 6px;
    font-size: 0.9rem;
}

/* ---------- Members table ---------- */
.members-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.members-table th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--gray-600);
    padding: 10px 12px;
    border-bottom: 2px solid var(--gray-200);
}
.members-table th.right,
.members-table td.right { text-align: right; }
.members-table td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}
.members-table tr:last-child td { border-bottom: none; }
.members-table .muted { color: var(--gray-600); font-size: 0.82rem; }
.members-table .small { font-size: 0.78rem; }

.member-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}
.member-name {
    font-weight: 600;
    color: var(--navy);
    font-size: 0.9rem;
}
.member-email {
    font-size: 0.78rem;
    color: var(--gray-600);
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ---------- Role legend ---------- */
.role-legend {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    align-items: center;
}
.role-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Key / value grid ---------- */
.kv-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px 32px;
    margin-top: 8px;
}
.kv-wide { grid-column: 1 / -1; }
.kv dt {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--gray-600);
    margin-bottom: 4px;
}
.kv dd {
    font-size: 0.95rem;
    color: var(--gray-800);
    line-height: 1.5;
}

/* ---------- Profile preview ---------- */
.profile-preview {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px;
    background: var(--gray-100);
    border-radius: 8px;
    margin-bottom: 22px;
}
.profile-preview-name {
    font-weight: 700;
    color: var(--navy);
    font-size: 1rem;
}
.profile-preview-meta {
    font-size: 0.82rem;
    color: var(--gray-600);
    margin-top: 3px;
}

/* ---------- Admin filter form ---------- */
.filter-form .filter-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.filter-form .field { margin-bottom: 0; }

/* ---------- Invite panel ---------- */
.invite-panel {
    background: var(--gray-100);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 20px;
    border-left: 3px solid var(--orange);
}
.invite-panel.hidden { display: none; }
.invite-form .invite-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.invite-form .field { margin-bottom: 0; }
.invite-form .hint {
    font-size: 0.78rem;
    color: var(--gray-600);
    margin-top: 10px;
}

/* ---------- Empty state (generic) ---------- */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.empty-state h3 {
    color: var(--navy);
    font-size: 1.15rem;
    margin: 16px 0 6px;
}
.empty-state p {
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-bottom: 20px;
}
.empty-icon svg { display: inline-block; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .kv-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .panel-block { padding: 16px; }
    .members-table th,
    .members-table td { padding: 8px; }
    .members-table { font-size: 0.82rem; }
    .inline-form { margin-left: 0; }
}