/* ============================================
   PDF Data Extractor - Modern UI Styles
   ============================================ */

/* CSS Variables */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --secondary-dark: #059669;
    --danger: #ef4444;
    --warning: #f59e0b;

    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border-color: #334155;
    --shadow-color: rgba(0, 0, 0, 0.3);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    background-image:
        radial-gradient(ellipse at top, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    color: var(--primary);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Drop Zone */
.drop-zone {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: 3rem 2rem;
    text-align: center;
    background: linear-gradient(145deg, var(--bg-secondary), var(--bg-primary));
    transition: var(--transition);
    cursor: pointer;
    overflow: hidden;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(16, 185, 129, 0.05));
    opacity: 0;
    transition: var(--transition);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 20px 40px var(--shadow-color);
}

.drop-zone:hover::before,
.drop-zone.drag-over::before {
    opacity: 1;
}

.drop-zone-content {
    position: relative;
    z-index: 1;
}

.drop-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--primary);
    animation: float 3s ease-in-out infinite;
}

.drop-icon svg {
    width: 100%;
    height: 100%;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.drop-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.drop-hint {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Processing Indicator */
.drop-zone-processing {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.95);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.drop-zone.processing .drop-zone-processing {
    display: flex;
}

.drop-zone.processing .drop-zone-content {
    opacity: 0.3;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.processing-status {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Action Buttons */
.actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* Stats */
.stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Table Container - Excel Style */
.table-container {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid #d0d7de;
    overflow: hidden;
    animation: fadeIn 0.5s ease-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: linear-gradient(180deg, #217346 0%, #185a34 100%);
    border-bottom: 1px solid #145a32;
}

.table-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-header h2::before {
    content: '';
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3Crect x='8' y='12' width='8' height='2'/%3E%3Crect x='8' y='16' width='8' height='2'/%3E%3C/svg%3E");
    background-size: contain;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-actions .btn-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.table-actions .btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

.table-wrapper {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    background: #ffffff;
    transition: max-height 0.3s ease-in-out;
}

.table-wrapper.expanded {
    max-height: none;
}

/* Excel-style Table */
table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
}

thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

th {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    color: #1a1a1a;
    font-weight: 600;
    font-size: 0.8125rem;
    text-align: left;
    padding: 0.625rem 0.75rem;
    border: 1px solid #d0d7de;
    border-top: none;
    white-space: nowrap;
    text-transform: none;
    letter-spacing: normal;
    position: relative;
}

th::after {
    content: '';
    position: absolute;
    right: 0;
    top: 25%;
    height: 50%;
    width: 1px;
    background: #c0c7ce;
}

th:last-child::after {
    display: none;
}

/* Row Numbers Column */
td:first-child,
th:first-child {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    color: #606770;
    font-weight: 500;
    text-align: center;
    min-width: 50px;
    border-right: 2px solid #d0d7de;
}

td {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #1a1a1a;
    background: #ffffff;
    border: 1px solid #e1e5e9;
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

tbody tr {
    transition: none;
}

tbody tr:hover td {
    background: #e8f4fd;
}

tbody tr:hover td:first-child {
    background: linear-gradient(180deg, #dce6f0 0%, #c8d6e5 100%);
}

/* Selected cell effect */
td:focus,
td:active {
    outline: 2px solid #217346;
    outline-offset: -2px;
    background: #e2efda;
}

/* Alternating row colors - subtle Excel style */
tbody tr:nth-child(even) td {
    background: #f8f9fa;
}

tbody tr:nth-child(even) td:first-child {
    background: linear-gradient(180deg, #f0f2f5 0%, #e4e7eb 100%);
}

tbody tr:nth-child(even):hover td {
    background: #e8f4fd;
}

tbody tr:nth-child(even):hover td:first-child {
    background: linear-gradient(180deg, #dce6f0 0%, #c8d6e5 100%);
}

/* Empty State - Excel Preview Style */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: var(--radius-md);
    border: 1px solid #d0d7de;
    margin-top: 1rem;
    position: relative;
    overflow: hidden;
}

.empty-state::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #217346, #2e8555);
}

/* Excel-like grid background */
.empty-state::after {
    content: '';
    position: absolute;
    inset: 40px 20px 60px 20px;
    background-image:
        linear-gradient(#e1e5e9 1px, transparent 1px),
        linear-gradient(90deg, #e1e5e9 1px, transparent 1px);
    background-size: 80px 32px;
    opacity: 0.6;
    pointer-events: none;
}

.empty-state svg {
    width: 60px;
    height: 60px;
    margin-bottom: 1rem;
    color: #217346;
    opacity: 0.8;
    position: relative;
    z-index: 1;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: #1a1a1a;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.empty-state .hint {
    font-size: 0.875rem;
    color: #606770;
    position: relative;
    z-index: 1;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px var(--shadow-color);
    border: 1px solid var(--border-color);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: var(--secondary);
}

.toast.error {
    border-color: var(--danger);
}

.toast.warning {
    border-color: var(--warning);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .drop-zone {
        padding: 2rem 1rem;
    }

    .drop-icon {
        width: 48px;
        height: 48px;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .stats {
        gap: 1rem;
    }

    .stat-item {
        padding: 0.75rem 1rem;
    }

    th,
    td {
        padding: 0.75rem 1rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Token Usage Footer */
.token-footer {
    margin-top: 2rem;
    padding: 1.5rem;
    background: linear-gradient(145deg, var(--bg-secondary), var(--bg-primary));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.token-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.token-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    min-width: 120px;
    transition: var(--transition);
}

.token-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.token-stat svg {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
}

.token-stat.total svg {
    color: var(--primary);
}

.token-stat.cost svg {
    color: var(--secondary);
}

.token-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.token-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.token-stat.total .token-value {
    color: var(--primary);
}

.token-stat.cost .token-value {
    color: var(--secondary);
}

@media (max-width: 768px) {
    .token-stats {
        gap: 1rem;
    }

    .token-stat {
        min-width: 100px;
        padding: 0.75rem 1rem;
    }

    .token-value {
        font-size: 1rem;
    }
}