/* Ghibli-Inspired Palette */
:root {
    --primary: #4a7c59;
    --primary-light: #5d9b6b;
    --primary-dark: #2d5a3f;
    --accent: #8fbc8f;
    --accent-light: #a8d4a8;
    --danger: #e85a4f;
    --warning: #f4a261;
    --success: #69b578;
    --info: #5b9aa0;
    --magical: #9b59b6;
    --forest: #355c3c;
    --sky: #a8dadc;
    --autumn: #d4a574;
    --moss: #7d8471;
    --sunrise: #ffd89b;

    --bg-primary: #fefefe;
    --bg-secondary: #f7fdf7;
    --bg-tertiary: #eef7ee;
    --bg-soft: #d8e8d8;
    --bg-gradient: linear-gradient(135deg, #f7fdf7 0%, #eef7ee 100%);
    --bg-magical: linear-gradient(135deg, #fef7f7 0%, #f0f9ff 100%);

    --text-primary: #2c3e30;
    --text-secondary: #4a6741;
    --text-tertiary: #6b8e6b;
    --text-muted: #9bb49b;
    --text-inverse: #ffffff;

    --border: #d4e6d4;
    --border-light: #e8f3e8;
    --border-soft: #c1d8c1;
    --shadow-sm: 0 2px 4px rgba(45, 90, 63, 0.08);
    --shadow-md: 0 4px 8px rgba(45, 90, 63, 0.12);
    --shadow-lg: 0 8px 16px rgba(45, 90, 63, 0.15);
    --shadow-xl: 0 16px 32px rgba(45, 90, 63, 0.2);
    --shadow-ghibli: 0 8px 32px rgba(139, 188, 143, 0.3);

    --radius-sm: 1rem;
    --radius-md: 1.5rem;
    --radius-lg: 2rem;
    --radius-xl: 3rem;
    --radius-organic: 1.5rem;

    --transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background:
        radial-gradient(circle at 20% 80%, rgba(139, 188, 143, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(168, 218, 220, 0.1) 0%, transparent 50%),
        linear-gradient(135deg, #f7fdf7 0%, #eef7ee 100%);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    position: relative;
    font-size: 16px;
    overflow-x: hidden;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Floating Ghibli Elements */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.particle {
    position: absolute;
    background: radial-gradient(circle, rgba(139, 188, 143, 0.4) 0%, rgba(139, 188, 143, 0.1) 70%, transparent 100%);
    border-radius: 50%;
    opacity: 0.6;
    animation: ghibliFloat 20s infinite ease-in-out;
}

.particle:nth-child(1) { width: 80px; height: 80px; left: 10%; top: 20%; animation-duration: 25s; animation-delay: 0s; }
.particle:nth-child(2) { width: 60px; height: 60px; right: 15%; top: 40%; animation-duration: 30s; animation-delay: -5s; }
.particle:nth-child(3) { width: 100px; height: 100px; left: 60%; bottom: 30%; animation-duration: 35s; animation-delay: -10s; }
.particle:nth-child(4) { width: 45px; height: 45px; right: 30%; bottom: 60%; animation-duration: 28s; animation-delay: -15s; }
.particle:nth-child(5) { width: 70px; height: 70px; left: 30%; top: 60%; animation-duration: 32s; animation-delay: -8s; }
.particle:nth-child(6) { width: 55px; height: 55px; left: 80%; top: 10%; animation-duration: 40s; animation-delay: -20s; }
.particle:nth-child(7) { width: 90px; height: 90px; right: 50%; top: 80%; animation-duration: 33s; animation-delay: -12s; }
.particle:nth-child(8) { width: 65px; height: 65px; left: 5%; bottom: 15%; animation-duration: 38s; animation-delay: -25s; }
.particle:nth-child(9) { width: 75px; height: 75px; right: 5%; top: 70%; animation-duration: 27s; animation-delay: -18s; }
.particle:nth-child(10) { width: 50px; height: 50px; left: 50%; bottom: 5%; animation-duration: 42s; animation-delay: -30s; }

@keyframes ghibliFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 0.3; }
    25% { transform: translateY(-20px) rotate(90deg); opacity: 0.6; }
    50% { transform: translateY(10px) rotate(180deg); opacity: 0.4; }
    75% { transform: translateY(-15px) rotate(270deg); opacity: 0.5; }
}

.particle {
    display: none;
}

/* Particles removed for cleaner look */

/* Float animation removed */

/* Header */
.header {
    background: linear-gradient(135deg, #f8f8f8 0%, #fafbfa 100%);
    border-bottom: 2px solid var(--accent-light);
    padding: 48px 0;
    position: relative;
    z-index: 10;
    box-shadow: var(--shadow-ghibli);
    margin-bottom: 40px;
}

.header-title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    color: #000000;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.header-subtitle {
    color: #333333;
    font-size: 1rem;
    text-align: center;
    margin-top: 0;
    font-weight: 400;
}

/* Cards - Enhanced with Bootstrap */
.card {
    background: var(--bg-primary);
    border: 2px solid var(--border);
    margin-bottom: 40px;
    transition: var(--transition);
    border-radius: var(--radius-organic);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg) !important;
    transform: translateY(-3px);
}

.card-header {
    padding: 32px 36px;
    border-bottom: 2px solid var(--border);
    background: linear-gradient(to right, var(--bg-secondary), var(--bg-primary));
    margin-bottom: 0;
    border-radius: var(--radius-organic) var(--radius-organic) 0 0;
}

.card-header h2 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
}

/* Upload Section */
.upload-area {
    padding: 60px 48px;
    border-style: dashed !important;
    border-color: var(--border-dark) !important;
    margin: 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-secondary);
    position: relative;
    border-radius: var(--radius-organic);
}

.upload-area:hover {
    border-color: var(--primary) !important;
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-sm);
    transform: scale(1.02);
}

.upload-area::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, var(--accent-light), var(--primary-light), var(--accent-light));
    border-radius: var(--radius-organic);
    opacity: 0;
    z-index: -1;
    animation: ghibliGlow 3s ease-in-out infinite alternate;
}

@keyframes ghibliGlow {
    0% { opacity: 0; transform: scale(1); }
    100% { opacity: 0.1; transform: scale(1.01); }
}

.upload-area.dragging {
    border-color: var(--success) !important;
    background: #e8f5e9;
}

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

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    color: var(--text-tertiary);
    transition: var(--transition);
}

.upload-area:hover .upload-icon {
    color: var(--text-secondary);
}

.upload-text p {
    font-size: 1rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-weight: 400;
}

.file-types {
    color: var(--text-tertiary);
    font-size: 0.813rem;
}

.upload-progress {
    display: none;
    margin-top: 24px;
}

.upload-area.processing .upload-content {
    display: none;
}

.upload-area.processing .upload-progress {
    display: block;
}

.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--success) 50%, var(--sky) 100%);
    width: 0;
    animation: progressAnimation 2s ease-in-out infinite;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 4px rgba(139, 188, 143, 0.3);
}

@keyframes progressAnimation {
    0% { width: 0; }
    50% { width: 60%; }
    100% { width: 100%; }
}

/* Selection Section */
.search-container {
    position: relative;
    margin: 32px 32px 24px 32px;
}

.search-input {
    width: 100%;
    padding: 14px 48px 14px 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-organic);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 188, 143, 0.2), var(--shadow-ghibli);
    transform: translateY(-2px);
}

.search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

/* Filters */
.filters {
    padding: 0 32px 24px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.filter-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
}

/* Filter buttons now use Bootstrap btn-group */
.filter-btn.active {
    background: linear-gradient(135deg, var(--forest) 0%, var(--accent-light) 100%) !important;
    border-color: var(--accent-light) !important;
    color: white !important;
    box-shadow: var(--shadow-ghibli) !important;
    position: relative;
    overflow: hidden;
}

.filter-btn:hover {
    transform: translateY(-1px);
    background: var(--bg-tertiary) !important;
    border-color: var(--accent-light) !important;
    box-shadow: 0 4px 12px rgba(139, 188, 143, 0.2) !important;
}

.btn-group .btn {
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
}

.btn-group .btn:first-child {
    margin-left: 0;
}

.btn-group .btn:last-child {
    margin-right: 0;
}

/* Underlying Grid */
.underlying-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 32px 36px 40px;
}

.underlying-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-organic);
    padding: 24px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.underlying-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(139, 188, 143, 0.1), transparent);
    transition: left 0.6s;
}

.underlying-card:hover {
    border-color: var(--accent-light);
    box-shadow: var(--shadow-ghibli);
    transform: translateY(-4px) rotate(-0.5deg);
    background: var(--bg-secondary);
}

.underlying-card:hover::before {
    left: 100%;
}

/* Multi-select mode styles */
.underlying-card.multi-select {
    cursor: pointer;
    user-select: none;
}

.underlying-checkbox {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.multi-select-mode .underlying-checkbox {
    display: flex;
}

.underlying-card.selected {
    border-color: var(--success);
    background: var(--bg-tertiary);
}

.underlying-card.selected .underlying-checkbox {
    background: var(--success);
    border-color: var(--success);
}

.underlying-checkbox i {
    color: white;
    font-size: 14px;
    display: none;
}

.underlying-card.selected .underlying-checkbox i {
    display: block;
}

/* Batch Actions Bar */
.batch-actions-bar {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    border-bottom: 2px solid var(--border);
    padding: 16px 24px !important;
    margin: 0;
}

.batch-actions-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: nowrap;
}

.selection-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.selected-count {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.batch-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}

.batch-buttons .btn {
    white-space: nowrap;
    padding: 0.5rem 1rem;
}

.underlying-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.underlying-info {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.underlying-info strong {
    color: var(--text-primary);
}

.underlying-types {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.type-badge {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.type-badge.CE, .type-badge.ce {
    background: linear-gradient(135deg, var(--success) 0%, #0ea272 100%);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}
.type-badge.PE, .type-badge.pe {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}
.type-badge.FUT, .type-badge.fut {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

/* Results Section */
.results-stats {
    display: flex;
    gap: 0;
    margin: 24px 0 32px 0;
    padding: 24px 0;
    background: linear-gradient(135deg, #ffffff 0%, var(--bg-secondary) 100%);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 24px;
    border-right: 1px solid var(--border-light);
}

.stat-item:last-child {
    border-right: none;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

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

.action-buttons {
    display: flex;
    gap: 8px;
}

/* Enhanced Bootstrap Buttons */
.btn {
    font-weight: 500;
    transition: var(--transition);
    border-radius: var(--radius-organic) !important;
    padding: 0.65rem 1.5rem;
    border-width: 1px;
}

.btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-ghibli);
    background-size: 110%;
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #0ea272 100%) !important;
    border-color: var(--success) !important;
}

.btn-outline-secondary {
    border-color: var(--border-soft) !important;
    color: var(--text-secondary) !important;
}

.btn-outline-secondary:hover {
    background: var(--bg-tertiary) !important;
    border-color: var(--primary-light) !important;
    color: var(--text-primary) !important;
}

.btn-icon {
    font-size: 1.1em;
}

/* Table */
.table-container {
    padding: 32px 32px 24px 32px;
    background: var(--bg-primary);
    margin-top: 0;
    border-radius: var(--radius-organic);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
    gap: 20px;
}

.table-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.form-select {
    border-radius: var(--radius-md) !important;
    border-color: var(--border-light) !important;
    padding: 10px 16px !important;
    min-width: 180px !important;
    font-size: 0.9rem !important;
}

.form-select:focus {
    border-color: var(--primary-light) !important;
    box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.15) !important;
}

.sort-select {
    padding: 8px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-primary);
    cursor: pointer;
    transition: var(--transition);
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-organic);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-primary);
}

.results-table thead {
    background: var(--bg-secondary);
}

.results-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

.results-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.results-table tbody tr:hover {
    background: var(--bg-secondary);
}

.results-table td {
    padding: 14px 16px;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.type-cell {
    display: inline-block;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.type-cell.CE {
    background: linear-gradient(135deg, var(--forest) 0%, var(--success) 100%);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--accent-light);
}
.type-cell.PE {
    background: linear-gradient(135deg, var(--autumn) 0%, var(--warning) 100%);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--sunrise);
}
.type-cell.FUT {
    background: linear-gradient(135deg, var(--sky) 0%, var(--info) 100%);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--sky);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
}

.pagination-btn {
    padding: 10px 20px;
    border: 2px solid var(--border);
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

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

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(79, 70, 229, 0.1);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    background: linear-gradient(135deg, #ffffff 0%, var(--bg-secondary) 100%);
    padding: 48px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

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

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

.loading-details {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Error Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    padding: 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-footer {
    padding: 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* Medium screens */
@media (max-width: 992px) {
    .batch-actions-content {
        flex-wrap: wrap;
    }

    .batch-buttons .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

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

    .underlying-grid {
        grid-template-columns: 1fr;
    }

    .table-wrapper {
        font-size: 0.875rem;
    }

    .results-stats {
        flex-direction: column;
        gap: 12px;
    }

    .action-buttons {
        flex-direction: column;
        width: 100%;
    }

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

    .batch-actions-bar {
        padding: 16px !important;
    }

    .batch-actions-content {
        flex-direction: column;
        gap: 12px;
        flex-wrap: wrap;
    }

    .selection-info {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .batch-buttons {
        width: 100%;
        justify-content: stretch;
        flex-direction: column;
    }

    .batch-buttons .btn {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    .particles-container,
    .header,
    .upload-section,
    .selection-section,
    .action-buttons,
    .pagination {
        display: none !important;
    }

    .results-table {
        font-size: 10pt;
    }
}