/*
 * ResumeAI Design System — Reusable Component Classes
 * Plain CSS (Tailwind CDN does not support @apply).
 * Use alongside Tailwind utilities for consistency.
 *
 * Usage: class="btn btn-primary" or class="input-field"
 */

/* ─── Buttons ─────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.25rem;
}

.btn-primary {
    background-color: #007AFF;
    color: #fff;
}
.btn-primary:hover { background-color: #0056CC; }

.btn-secondary {
    border: 1px solid #E5E7EB;
    color: #1D1D1F;
    background: #fff;
}
.btn-secondary:hover { background-color: #F9FAFB; }

.btn-danger {
    border: 1px solid #FECACA;
    color: #FF3B30;
    background: #fff;
}
.btn-danger:hover { background-color: #FEF2F2; }

.btn-ghost {
    color: #86868B;
    background: transparent;
}
.btn-ghost:hover { color: #1D1D1F; background-color: #F9FAFB; }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* ─── Cards ───────────────────────────────────────────────────────────── */

.card {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid #E5E7EB;
}

.card-padded {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid #E5E7EB;
    padding: 1.5rem;
}

.card-hover {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}
.card-hover:hover {
    border-color: #BFDBFE;
    box-shadow: 0 4px 6px rgba(0,0,0,0.07);
}

/* ─── Inputs ──────────────────────────────────────────────────────────── */

.input-field {
    width: 100%;
    border: 1px solid #E5E7EB;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    color: #1D1D1F;
    font-size: 0.875rem;
    background: #fff;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-field:focus {
    border-color: #007AFF;
    box-shadow: 0 0 0 1px #007AFF;
}

.input-field-sm {
    width: 100%;
    border: 1px solid #E5E7EB;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: #1D1D1F;
    font-size: 0.875rem;
    background: #fff;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-field-sm:focus {
    border-color: #007AFF;
    box-shadow: 0 0 0 1px #007AFF;
}

/* ─── Badges ──────────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #DCFCE7; color: #15803D; }
.badge-warning { background: #FEF9C3; color: #A16207; }
.badge-error   { background: #FEE2E2; color: #B91C1C; }
.badge-neutral { background: #F3F4F6; color: #86868B; }
.badge-primary { background: rgba(0,122,255,0.1); color: #007AFF; }

/* ─── Links ───────────────────────────────────────────────────────────── */

.link-danger { color: #FF3B30; font-size: 0.875rem; text-decoration: none; }
.link-danger:hover { color: #DC2626; }

.link-primary { color: #007AFF; font-size: 0.875rem; font-weight: 500; text-decoration: none; }
.link-primary:hover { color: #0056CC; }

/* ─── Button Variants (extra) ────────────────────────────────────────── */

.btn-warning {
    background-color: #F59E0B;
    color: #fff;
}
.btn-warning:hover { background-color: #D97706; }

.btn-success {
    background-color: #34C759;
    color: #fff;
}
.btn-success:hover { background-color: #2DA44E; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: #86868B;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
}
.btn-icon:hover {
    background-color: #F3F4F6;
    color: #1D1D1F;
}

/* Button states */
.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn:focus-visible {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

/* Loading state — add .btn-loading to any .btn */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.btn-loading.btn-secondary::after,
.btn-loading.btn-ghost::after {
    border-color: rgba(0,0,0,0.15);
    border-top-color: #1D1D1F;
}

/* ─── Select Inputs ──────────────────────────────────────────────────── */

.input-select {
    width: 100%;
    border: 1px solid #E5E7EB;
    border-radius: 0.5rem;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    color: #1D1D1F;
    font-size: 0.875rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2386868B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.5rem center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-select:focus {
    border-color: #007AFF;
    box-shadow: 0 0 0 1px #007AFF;
}

/* ─── Page Layout ────────────────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1D1D1F;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.page-subtitle {
    font-size: 0.875rem;
    color: #86868B;
    margin-top: 0.25rem;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #86868B;
    margin-bottom: 0.75rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1D1D1F;
}

/* ─── Empty States ───────────────────────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state-icon {
    width: 3rem;
    height: 3rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: #F3F4F6;
    color: #86868B;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.empty-state-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1D1D1F;
    margin-bottom: 0.5rem;
}

.empty-state-desc {
    font-size: 0.875rem;
    color: #86868B;
    max-width: 24rem;
    margin-bottom: 1.5rem;
}

/* ─── Table Container ────────────────────────────────────────────────── */

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 1rem;
    border: 1px solid #E5E7EB;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
}

.table-container thead {
    background: #F9FAFB;
}

.table-container th {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #86868B;
    text-align: left;
    white-space: nowrap;
}

.table-container td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #1D1D1F;
    border-top: 1px solid #F3F4F6;
}

.table-container tbody tr {
    transition: background-color 0.1s ease;
}
.table-container tbody tr:hover {
    background-color: #F9FAFB;
}

/* ─── Alerts ─────────────────────────────────────────────────────────── */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    border: 1px solid;
}

.alert-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.0625rem;
}

.alert-info {
    background: #EFF6FF;
    border-color: #BFDBFE;
    color: #1E40AF;
}

.alert-success {
    background: #F0FDF4;
    border-color: #BBF7D0;
    color: #15803D;
}

.alert-warning {
    background: #FFFBEB;
    border-color: #FDE68A;
    color: #A16207;
}

.alert-error {
    background: #FEF2F2;
    border-color: #FECACA;
    color: #B91C1C;
}

/* ─── Breadcrumbs ────────────────────────────────────────────────────── */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #86868B;
    margin-bottom: 1.5rem;
}

.breadcrumb a {
    color: #86868B;
    text-decoration: none;
    transition: color 0.15s ease;
}
.breadcrumb a:hover {
    color: #1D1D1F;
}

.breadcrumb-separator {
    color: #D1D5DB;
    font-size: 0.75rem;
}

.breadcrumb-current {
    color: #1D1D1F;
    font-weight: 500;
}

/* ─── Stat Cards ─────────────────────────────────────────────────────── */

.stat-card {
    background: #fff;
    border-radius: 1rem;
    border: 1px solid #E5E7EB;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    padding: 1.5rem;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1D1D1F;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-card-label {
    font-size: 0.75rem;
    color: #86868B;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* ─── Avatar ─────────────────────────────────────────────────────────── */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background: rgba(0,122,255,0.1);
    color: #007AFF;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.avatar-sm {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.625rem;
}

.avatar-lg {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 0.875rem;
}

/* ─── Spinners ───────────────────────────────────────────────────────── */

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid #E5E7EB;
    border-top-color: #007AFF;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-sm {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

.spinner-lg {
    width: 2rem;
    height: 2rem;
    border-width: 3px;
}

/* ─── Skeleton Loading ───────────────────────────────────────────────── */

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}

.skeleton-text {
    height: 0.875rem;
    margin-bottom: 0.5rem;
}

.skeleton-heading {
    height: 1.25rem;
    width: 60%;
    margin-bottom: 0.75rem;
}

.skeleton-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
}

.skeleton-card {
    height: 8rem;
    border-radius: 1rem;
}

/* ─── Pagination ─────────────────────────────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 2rem;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #86868B;
    text-decoration: none;
    transition: all 0.15s ease;
}

.pagination a:hover {
    background: #F3F4F6;
    color: #1D1D1F;
}

.pagination .active {
    background: #007AFF;
    color: #fff;
}

.pagination .disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ─── Modal ──────────────────────────────────────────────────────────── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 50;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.modal-backdrop.active {
    opacity: 1;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    z-index: 51;
    width: 100%;
    max-width: 28rem;
    max-height: 90vh;
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.modal.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    padding: 1.5rem 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 1rem 1.5rem;
}

.modal-footer {
    padding: 0 1.5rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ─── Tooltip ────────────────────────────────────────────────────────── */

[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.375rem 0.75rem;
    background: #1D1D1F;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.375rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 40;
}
[data-tooltip]:hover::after {
    opacity: 1;
}

/* ─── Transitions & Animations ───────────────────────────────────────── */

@keyframes fade-in {
    from { opacity: 0; transform: translateY(0.5rem); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fade-in 0.3s ease-out;
}

/* ─── Screen Reader Only ─────────────────────────────────────────────── */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ─── Detail Nav (Prev/Next) ─────────────────────────────────────────── */

.detail-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 0.75rem;
    padding: 0.25rem;
    margin-bottom: 1rem;
    gap: 0.25rem;
}

.detail-nav-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.875rem;
    border-radius: 0.625rem;
    text-decoration: none;
    color: #1D1D1F;
    transition: all 0.15s ease;
    min-height: 2.75rem;
    min-width: 11rem;
    cursor: pointer;
    user-select: none;
}
.detail-nav-btn:hover { background: #F7F8FA; }
.detail-nav-btn:active { transform: scale(0.98); }
.detail-nav-btn.disabled {
    opacity: 0.25;
    pointer-events: none;
}

.detail-nav-prev { justify-content: flex-start; }
.detail-nav-next { justify-content: flex-end; text-align: right; }

.detail-nav-hint {
    display: block;
    font-size: 0.6875rem;
    color: #86868B;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.detail-nav-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1D1D1F;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 12.5rem;
}
.detail-nav-sublabel {
    display: inline;
    font-size: 0.6875rem;
    font-weight: 400;
    color: #86868B;
    margin-left: 0.25rem;
}

.detail-nav-counter {
    font-size: 0.75rem;
    color: #86868B;
    font-weight: 500;
    white-space: nowrap;
    padding: 0 0.5rem;
    flex-shrink: 0;
}

.detail-nav-chevron {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    color: #86868B;
}
.detail-nav-btn:hover .detail-nav-chevron { color: #007AFF; }

/* Job badge for conversation header */
.conv-job-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 500;
    background: #f0f5ff;
    color: #007AFF;
    border: 1px solid #d4e3fc;
}
.conv-job-badge svg { width: 0.75rem; height: 0.75rem; }

/* ─── Divider ────────────────────────────────────────────────────────── */

.divider {
    height: 1px;
    background: #E5E7EB;
    margin: 1.5rem 0;
}
