@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #00472f;
    /* CCU Dark Green (Runea Institutional) */
    --primary-light: #4fba3d;
    /* CCU Light Green */
    --accent: #4fba3d;
    --bg-dark: #0a0e0c;
    /* Deep custom dark with green undertone */
    --bg-card: rgba(255, 255, 255, 0.03);
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
    --text: #ffffff;
    --text-muted: #94a3b8;
    --success: #22c55e;
    --error: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px 40px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: rgba(10, 14, 12, 0.8);
    backdrop-filter: blur(20px);
    z-index: 1000;
}

.runea-logo {
    height: 48px;
    filter: drop-shadow(0 0 10px rgba(79, 186, 61, 0.3));
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(to right, #60a5fa, #2563eb);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.8;
}

.price-list-status {
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.price-list-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.price-list-status.ok {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.2);
}

.price-list-status.ok::before {
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.price-list-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.2);
}

.price-list-status.error::before {
    background-color: var(--error);
}

.price-list-status.pending {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.2);
}


.input-group {
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input,
select {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 14px;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(79, 186, 61, 0.1);
    background-color: rgba(0, 0, 0, 0.5);
}

.button-row {
    flex-basis: 100%;
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

button {
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

button:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #003020 100%);
    color: white;
    flex: 2;
    box-shadow: 0 4px 15px rgba(0, 71, 47, 0.3);
    border: 1px solid rgba(79, 186, 61, 0.2);
}

.btn-primary:hover {
    filter: brightness(1.2);
    box-shadow: 0 8px 25px rgba(0, 71, 47, 0.4);
}

.btn-secondary {
    background-color: var(--glass);
    color: var(--text);
    flex: 1;
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background-color: var(--border);
    color: white;
}

.results-container {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    border: 1px solid var(--border);
    overflow: hidden;
    /* This might clip suggestions if not careful, but controls is a sibling */
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 10;
    /* Lower than controls z-index: 50 */
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

th {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 20px;
    font-weight: 600;
    color: var(--primary-light);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
}

tr:hover td {
    background-color: rgba(79, 186, 61, 0.02);
}

tr:last-child td {
    border-bottom: none;
}

.badge-discount {
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.badge-discount.positive {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.badge-discount.negative {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.badge-discount.warning {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.btn-delete {
    background: none;
    color: var(--error);
    padding: 4px;
    font-size: 1rem;
    opacity: 0.5;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-delete:hover {
    opacity: 1;
    transform: scale(1.2);
}

.action-cell {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    white-space: nowrap;
}

/* Snackbar */
.snackbar {
    visibility: hidden;
    min-width: 300px;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    color: #fff;
    text-align: center;
    border-radius: 12px;
    padding: 16px 24px;
    position: fixed;
    z-index: 2000;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.snackbar.show {
    visibility: visible;
    animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slideUp {
    from {
        bottom: 0;
        opacity: 0;
    }

    to {
        bottom: 40px;
        opacity: 1;
    }
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 2px;
}

.tab-btn {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 12px 24px;
    border-radius: 14px 14px 0 0;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tab-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-light);
    border-bottom: none;
    box-shadow: 0 -4px 15px rgba(0, 71, 47, 0.2);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.tab-content.show {
    animation: fadeInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.99);
    }

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

/* Order Module Specifics */
.order-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-light);
}

.stat-card .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary-light);
    text-shadow: 0 0 20px rgba(79, 186, 61, 0.2);
}

.controls {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 50;
    /* Ensure controls (and suggestions) stay above the results table */
}

.search-group {
    position: relative;
}

.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(10, 14, 12, 0.98);
    backdrop-filter: blur(25px);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-top: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 3000;
    /* Extremely high to beat any table headers or glass effects */
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 20px rgba(79, 186, 61, 0.1);
    display: none;
}

.autocomplete-suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: rgba(79, 186, 61, 0.1);
}

.suggestion-item .art-code {
    font-weight: 700;
    color: var(--primary-light);
    font-size: 0.85rem;
    background: rgba(79, 186, 61, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
}

.suggestion-item .art-desc {
    flex: 1;
    margin-left: 12px;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

/* Scrollbar personalizado para las sugerencias */
.autocomplete-suggestions::-webkit-scrollbar {
    width: 6px;
}

.autocomplete-suggestions::-webkit-scrollbar-track {
    background: transparent;
}

.autocomplete-suggestions::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.autocomplete-suggestions::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Mobile adjustments */
@media (max-width: 900px) {
    .container {
        padding: 20px;
    }

    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        align-items: center;
    }

    .header-right {
        align-items: center;
    }

    .controls {
        padding: 20px;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        border-radius: 12px;
    }
}