:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #f3f4f6;
    --sidebar-bg: #1e293b;
    --sidebar-text: #f8fafc;
    --border: #e5e7eb;
    --white: #ffffff;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Global Navigation Sidebar */
.nav-panel {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: width 0.3s ease;
    position: relative;
}

.nav-panel.collapsed {
    width: 64px;
}

.nav-header {
    padding: 0 20px 30px;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: white;
}

.nav-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 500;
    color: #94a3b8;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

main {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    padding: 16px;
    gap: 16px;
}

/* Sidebar Section (Product List) */
.sidebar {
    width: 380px;
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    transition: width 0.30s ease, margin-left 0.3s ease, opacity 0.3s ease;
}

.sidebar.collapsed {
    width: 0;
    margin-left: -16px;
    border: none;
    opacity: 0;
    pointer-events: none;
}

.search-bar {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.search-bar input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.items-list {
    flex-grow: 1;
    overflow-y: auto;
}

.product-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    gap: 12px;
    align-items: center;
    transition: background 0.1s;
}

.product-item:hover {
    background: #f8fafc;
}

.product-item.active {
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
}

.item-thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
    background: var(--white);
    padding: 4px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* Detail Section */
.detail-section {
    flex-grow: 1;
    background: var(--white);
    padding: 32px;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.product-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 24px;
}

.product-table th,
.product-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.product-table th {
    background: #f8fafc;
    width: 180px;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.product-table td {
    font-size: 0.95rem;
    color: var(--text);
}

.product-table td pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    background: #f8fafc;
    padding: 12px;
    border-radius: 6px;
}

.pagination {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: center;
    background: #f8fafc;
}

button {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

button:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}

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

.btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn-secondary:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-badge.paid {
    background: #dcfce7;
    color: #166534;
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.refunded {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.partially_paid {
    background: #dbeafe;
    color: #1e40af;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* Orders Container */
.orders-container {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
}

.orders-container table {
    margin-top: 0;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-card {
    background: var(--white);
    padding: 32px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.login-card h2 {
    margin: 0 0 8px 0;
    font-size: 1.5rem;
    color: var(--text);
}

.login-card p {
    margin: 0 0 24px 0;
    color: var(--text-light);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-button {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-button:hover {
    background: #1d4ed8;
}

.login-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error-message {
    color: #dc2626;
    background: #fef2f2;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    border: 1px solid #fee2e2;
}

.pinned-badge {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #fde68a;
}

.pin-icon-btn {
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
}

.pin-icon-btn:hover {
    background: var(--bg);
}

.pin-icon-btn.pinned {
    background: #fffbeb;
    border-color: #fde68a;
    color: #d97706;
}

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

/* Collapse Toggles */
.collapse-toggle {
    position: absolute;
    bottom: 20px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid var(--white);
    z-index: 10;
    box-shadow: var(--shadow);
}

.nav-panel.collapsed .nav-header {
    opacity: 0;
    white-space: nowrap;
}

.nav-panel.collapsed .nav-item span {
    display: none;
}

.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-light);
    cursor: pointer;
    margin-right: 16px;
}

.sidebar-toggle-btn:hover {
    background: var(--border);
}

.item-badge-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pinned-overlay {
    position: absolute;
    top: -6px;
    left: -6px;
    background: #f59e0b;
    color: white;
    padding: 2px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Parameters Page Styles */
.parameters-container {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    padding: 20px 0;
}

.parameter-card {
    background: var(--white);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 40px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.parameter-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.parameter-meta {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-light);
    padding: 4px 12px;
    border-radius: 20px;
}

.prompt-textarea-wrapper {
    position: relative;
    margin-top: 24px;
}

.prompt-textarea {
    width: 100%;
    min-height: 500px;
    padding: 24px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fbfcfd;
    color: #334155;
}

.prompt-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
    background: white;
}

.save-section {
    display: flex;
    justify-content: flex-end;
    margin-top: 32px;
}

.save-button {
    padding: 12px 40px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}