/* ============================================
   Glass UI v2 — "Luminous Paper" aesthetic
   Distinctive glassmorphism + editorial warmth
   ============================================ */

:root {
    --glass-bg: rgba(255, 255, 255, 0.78);
    --glass-border: rgba(200, 200, 220, 0.35);
    --glass-blur: 20px;
    --glass-shadow:
        0 4px 24px rgba(139, 92, 246, 0.1),
        0 16px 56px rgba(139, 92, 246, 0.08),
        0 1px 0 rgba(255, 255, 255, 0.7) inset;
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --accent: #f59e0b;
    --accent-soft: rgba(245, 158, 11, 0.08);
}

/* ---- Animated Background ---- */
.glass-bg {
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 50%, #faf5ff 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.glass-bg::before,
.glass-bg::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.7;
    z-index: 0;
    pointer-events: none;
    will-change: transform;
}

.glass-bg::before {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.22), transparent 70%);
    top: -10%;
    right: -5%;
    animation: floatOrb1 20s ease-in-out infinite;
}

.glass-bg::after {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.16), transparent 70%);
    bottom: -10%;
    left: -5%;
    animation: floatOrb2 25s ease-in-out infinite;
}

@keyframes floatOrb1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(-60px, 80px) scale(1.1); }
    66%      { transform: translate(40px, -40px) scale(0.95); }
}

@keyframes floatOrb2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(80px, -60px) scale(1.05); }
    66%      { transform: translate(-50px, 50px) scale(0.9); }
}

/* Third orb via extra element */
.glass-orb-3 {
    position: fixed;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.15), transparent 70%);
    filter: blur(80px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: floatOrb3 18s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes floatOrb3 {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-30%, -60%) scale(1.15); }
}

/* Noise/grain overlay — separate element, not pseudo */
.glass-noise {
    position: fixed;
    inset: 0;
    opacity: 0.025;
    pointer-events: none;
    z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* ---- Glassmorphism card (enhanced) ---- */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    transition: box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    box-shadow:
        0 8px 32px rgba(139, 92, 246, 0.14),
        0 20px 60px rgba(139, 92, 246, 0.1),
        0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

/* Gradient border variant */
.glass-card-gradient {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: none;
    box-shadow: var(--glass-shadow);
}

.glass-card-gradient::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(245, 158, 11, 0.2), rgba(6, 182, 212, 0.2));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* ---- Entrance Animations ---- */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateX(-16px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeScale {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

.animate-in {
    animation: fadeSlideUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.animate-in-delay-1 { animation-delay: 0.08s; }
.animate-in-delay-2 { animation-delay: 0.16s; }
.animate-in-delay-3 { animation-delay: 0.24s; }
.animate-in-delay-4 { animation-delay: 0.32s; }
.animate-in-delay-5 { animation-delay: 0.4s; }

.animate-scale {
    animation: fadeScale 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ---- Notification (JS: className = `notification ${type} show`) ---- */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 24px;
    border-radius: 14px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 2000;
    transform: translateX(400px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 1px 0 rgba(255,255,255,0.2) inset;
}
.notification.show {
    transform: translateX(0);
    opacity: 1;
}
.notification.success { background: rgba(16, 185, 129, 0.9); }
.notification.error   { background: rgba(244, 63, 94, 0.9); }

/* ---- Modal (JS: classList.add/remove 'active') ---- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.active { display: flex; }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.modal-overlay.active { display: flex; }

/* ---- Progress bar ---- */
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6 0%, #a78bfa 40%, #f59e0b 100%);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 9999px;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

/* ---- Editable cells ---- */
.editable-cell {
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}
.editable-cell:hover {
    background: rgba(139, 92, 246, 0.05) !important;
    box-shadow: inset 0 0 0 2px var(--primary);
}
.cell-modified {
    background: rgba(245, 158, 11, 0.08) !important;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.3);
}
.cell-edit-input {
    width: 100%;
    border: none;
    outline: 2px solid var(--primary);
    background: #fff;
    padding: 6px 8px;
    font-size: 0.9em;
    font-family: inherit;
    box-sizing: border-box;
    min-width: 60px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.12);
}
.editable-header {
    padding: 10px 6px !important;
    font-size: 0.75em !important;
    white-space: nowrap;
}
.display-header {
    background: linear-gradient(135deg, #a78bfa 0%, #c4b5fd 100%) !important;
    padding: 10px 12px !important;
    font-size: 0.78em !important;
    font-weight: 700 !important;
    text-transform: none !important;
    letter-spacing: 0.02em !important;
    white-space: nowrap;
    border-bottom: 2px solid rgba(255, 255, 255, 0.35);
}
.btn-delete-row {
    background: none;
    border: none;
    color: #f43f5e;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.85em;
    border-radius: 8px;
    opacity: 0.4;
    transition: all 0.25s ease;
}
.btn-delete-row:hover {
    opacity: 1;
    background: rgba(244, 63, 94, 0.08);
    transform: scale(1.1);
}

/* ---- Mapping file status ---- */
.mapping-file-status { font-size: 0.8rem; margin: 6px 0 0 0; }
.mapping-file-status.success { color: #059669; }
.mapping-file-status.error   { color: #e11d48; }

/* ---- JS-generated document items ---- */
.document-item {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 20px 24px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 20px;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.document-item:hover {
    background: rgba(255, 255, 255, 0.75);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.08), 0 1px 0 rgba(255,255,255,0.5) inset;
}
.document-info h3 {
    color: #1e293b;
    margin-bottom: 8px;
    font-size: 1.15em;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.document-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: #475569;
    font-size: 0.92em;
}
.document-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}
.document-actions {
    display: flex;
    gap: 10px;
}

/* ---- Buttons ---- */
.btn {
    padding: 11px 24px;
    border: none;
    border-radius: 12px;
    font-size: 0.93em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    letter-spacing: -0.01em;
}
.btn-primary {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.25);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35);
}
.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.25);
}
.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.7);
    color: #475569;
    border: 1px solid rgba(148, 163, 184, 0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(139, 92, 246, 0.2);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.06);
}
.btn-danger {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: white;
    padding: 8px 16px;
    font-size: 0.86em;
    box-shadow: 0 2px 12px rgba(244, 63, 94, 0.25);
}
.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(244, 63, 94, 0.35);
}
.btn-info {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: white;
    padding: 8px 16px;
    font-size: 0.86em;
    box-shadow: 0 2px 12px rgba(14, 165, 233, 0.25);
}
.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 0.82em;
}

/* ---- Placeholders ---- */
.no-documents {
    text-align: center;
    color: #94a3b8;
    padding: 48px;
    font-size: 1em;
}
.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}
.no-data i {
    font-size: 3.5em;
    margin-bottom: 16px;
    color: #cbd5e1;
}
.no-data p {
    font-size: 1em;
    margin: 8px 0;
}
.no-data p:first-of-type {
    font-weight: 600;
    color: #64748b;
}

/* ---- Data summary / table wrapper ---- */
.data-summary {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 16px;
}
.table-wrapper {
    margin-top: 20px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.5);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.03);
}

/* ---- Extracted table ---- */
.extracted-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.5);
    min-width: 800px;
}
.extracted-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 60%, #a78bfa 100%);
}
.extracted-table th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.12);
}
.extracted-table th:last-child { border-right: none; }
.extracted-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(241, 245, 249, 0.7);
    border-right: 1px solid rgba(241, 245, 249, 0.5);
    color: #334155;
    font-size: 0.88em;
    max-width: 300px;
    word-wrap: break-word;
}
.extracted-table td:last-child { border-right: none; }
.extracted-table tbody tr { transition: background 0.2s ease; }
.extracted-table tbody tr:hover { background: rgba(139, 92, 246, 0.03); }
.extracted-table tbody tr:nth-child(even) { background: rgba(248, 250, 252, 0.4); }
.extracted-table tbody tr:nth-child(even):hover { background: rgba(139, 92, 246, 0.04); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .document-item { grid-template-columns: 1fr; }
    .document-actions { flex-direction: column; }
    .document-actions .btn { width: 100%; justify-content: center; }
    .data-summary { flex-direction: column; }
    .glass-bg::before { width: 300px; height: 300px; }
    .glass-bg::after  { width: 250px; height: 250px; }
    .glass-orb-3      { width: 200px; height: 200px; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .glass-bg::before,
    .glass-bg::after,
    .glass-orb-3 { animation: none; }
    .animate-in,
    .animate-scale { animation: none; opacity: 1; transform: none; }
    .notification { transition: opacity 0.2s ease; }
}
