/* ═══════════════════════════════════════════════════════════════════
   Shared Base Styles — Invoice Parser
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}
body {
    background: #f8fafc;
    font-family:
        "Inter",
        system-ui,
        -apple-system,
        sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    color: #1e293b;
}

/* ── Accessible skip link ── */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #1e293b;
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
}

/* ── Drop zone (upload area) ── */
.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    transition:
        border-color 0.2s,
        background 0.2s,
        transform 0.15s;
    cursor: pointer;
}
.drop-zone.active {
    border-color: #3b82f6;
    background: #eff6ff;
    transform: scale(1.01);
}
.drop-zone.has-files {
    border-style: solid;
    border-color: #94a3b8;
}
.drop-zone:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* ── File items in the drop zone list ── */
.file-item {
    transition: background 0.15s;
}
.file-item:hover {
    background: #f1f5f9;
}

/* ── Status dots for file processing state ── */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-dot.pending {
    background: #94a3b8;
}
.status-dot.processing {
    background: #f59e0b;
    animation: pulse 1s infinite;
}
.status-dot.success {
    background: #22c55e;
}
.status-dot.error {
    background: #ef4444;
}
@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ── Data grid tables ── */
.grid-container {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
}
.grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.grid-table th {
    background: #1e293b;
    color: white;
    padding: 10px 12px;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
    font-weight: 600;
    font-size: 13px;
}
.grid-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}
.grid-table tr:nth-child(even) td {
    background: #f8fafc;
}
.grid-table tr:hover td {
    background: #e2e8f0;
}
.grid-table td[contenteditable="true"] {
    cursor: text;
    outline: none;
    border-radius: 4px;
    min-width: 60px;
}
.grid-table td[contenteditable="true"]:focus {
    background: #fef9c3;
    box-shadow: inset 0 0 0 2px #eab308;
}
.grid-table td.modified {
    background: #fef9c3 !important;
}

/* ── Tab buttons ── */
.tab-btn {
    padding: 10px 20px;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    cursor: pointer;
    transition:
        border-color 0.15s,
        color 0.15s;
    color: #475569;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab-btn.active {
    color: #1e293b;
    border-bottom-color: #3b82f6;
}
.tab-btn:hover {
    color: #1e293b;
}

/* ── Indigo button variant ── */
.btn-indigo {
    background: #4f46e5;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition:
        background 0.15s,
        transform 0.1s;
}
.btn-indigo:hover:not(:disabled) {
    background: #4338ca;
}
.btn-indigo:active:not(:disabled) {
    transform: scale(0.97);
}
.btn-indigo:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── 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-width: 0;
}

/* ── Card ── */
.card p:last-child {
    margin-bottom: 0;
}

.card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 24px;
}

/* ── Stats ── */
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
}
.stat-label {
    font-size: 0.85rem;
    color: #475569;
    margin-top: 2px;
}

/* ── Buttons ── */
.btn-primary {
    background: #1e293b;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition:
        background 0.15s,
        transform 0.1s;
}
.btn-primary:hover:not(:disabled) {
    background: #334155;
}
.btn-primary:active:not(:disabled) {
    transform: scale(0.97);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-export {
    background: #16a34a;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition:
        background 0.15s,
        transform 0.1s;
}
.btn-export:hover:not(:disabled) {
    background: #15803d;
}
.btn-export:active:not(:disabled) {
    transform: scale(0.97);
}
.btn-export:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    display: inline-block;
}
.btn-secondary.hidden {
    display: none !important;
}
.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: #ef4444;
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.85rem;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-danger:hover {
    background: #dc2626;
}
.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Modal overlay ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.modal-box {
    background: white;
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
.modal-box h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #1e293b;
}
.modal-box label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 4px;
}
.modal-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.15s;
}
.modal-box input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.modal-error {
    color: #ef4444;
    font-size: 0.85rem;
    margin-bottom: 12px;
    min-height: 1.2em;
}
.switch-auth {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: #475569;
}
.switch-auth a {
    color: #3b82f6;
    cursor: pointer;
    font-weight: 500;
}
.switch-auth a:hover {
    text-decoration: underline;
}

/* ── Invoice list item ── */
.invoice-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 6px;
    transition: background 0.1s;
    cursor: pointer;
}
.invoice-list-item:hover {
    background: #f8fafc;
}
.invoice-list-item.selected {
    background: #eff6ff;
    border-color: #93c5fd;
}
.invoice-list-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #3b82f6;
    flex-shrink: 0;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(10px);
    transition:
        opacity 0.3s,
        transform 0.3s;
    z-index: 200;
    pointer-events: none;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast.success {
    background: #16a34a;
    color: white;
}
.toast.error {
    background: #ef4444;
    color: white;
}

/* ── Spinner ── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── FAQ page ── */
.faq-details {
    border-bottom: 1px solid #f1f5f9;
    padding: 16px 0;
}
.faq-details:first-of-type {
    padding-top: 0;
}
.faq-details:last-of-type {
    border-bottom: none;
}
.faq-summary {
    cursor: pointer;
    font-weight: 600;
    color: #1e293b;
    font-size: 1rem;
}
.faq-summary::-webkit-details-marker {
    color: #94a3b8;
}
.faq-answer {
    color: #475569;
    margin-top: 8px;
    line-height: 1.6;
}

/* ── Usage / data tables ── */
.usage-table {
    width: 100%;
    border-collapse: collapse;
}
.usage-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e2e8f0;
}
.usage-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
}
.usage-table tr:last-child td {
    border-bottom: none;
}

/* ── Form inputs ── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
    transition: border-color 0.15s;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ── Field rows (advanced mode) ── */
.field-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.field-row input,
.field-row select {
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
}
.field-row input:focus,
.field-row select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.field-row input {
    flex: 1;
    min-width: 0;
}
.field-row select {
    width: 100px;
    flex-shrink: 0;
}

/* ── Schema card ── */
.schema-card {
    transition: border-color 0.15s;
}
.schema-card:hover {
    border-color: #c7d2fe;
}

/* ── Reset password page ── */
.reset-card {
    max-width: 420px;
    width: 100%;
    padding: 32px;
}
.reset-card .btn-primary {
    width: 100%;
}
.reset-card input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
}
.reset-card input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.reset-card label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}
.reset-error {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ── Accessibility: visible focus ring ── */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ── Reduce motion for users who prefer it ── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
