* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-alt: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Dark mode variables */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary-color: #94a3b8;
    --success-color: #4ade80;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-alt: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #475569;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: background-color 0.3s;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

header h1 {
    color: var(--primary-color);
    font-size: 2rem;
}

.btn-icon {
    background: var(--surface-alt);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s;
}

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

/* Dark mode toggle icons */
.icon-sun {
    display: none;
}

.icon-moon {
    display: inline;
}

[data-theme="dark"] .icon-sun {
    display: inline;
}

[data-theme="dark"] .icon-moon {
    display: none;
}

.hospital-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

.hospital-info p {
    margin: 5px 0;
}

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }
}

section {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: background-color 0.3s;
}

section h2 {
    font-size: 1.25rem;
    margin-bottom: 15px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.search-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

#search-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, background-color 0.3s;
    background: var(--surface);
    color: var(--text-primary);
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

#search-input::placeholder {
    color: var(--text-secondary);
}

#price-type {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.3s;
}

.search-results {
    max-height: 500px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background-color 0.2s, transform 0.1s;
}

.search-result-item:hover {
    background-color: var(--surface-alt);
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-description {
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-word;
}

.item-code {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.item-drug-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 4px;
}

/* Standardized drug info styling */
.item-dose-info {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.dose-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

.dose-badge.strength {
    background: #dbeafe;
    color: #1e40af;
}

.dose-badge.route {
    background: #dcfce7;
    color: #166534;
}

.dose-badge.form {
    background: #fef3c7;
    color: #92400e;
}

.dose-badge.unit-price {
    background: #f3e8ff;
    color: #7c3aed;
}

.dose-badge.package {
    background: #e0e7ff;
    color: #4338ca;
}

[data-theme="dark"] .dose-badge.strength {
    background: #1e3a5f;
    color: #93c5fd;
}

[data-theme="dark"] .dose-badge.route {
    background: #14532d;
    color: #86efac;
}

[data-theme="dark"] .dose-badge.form {
    background: #78350f;
    color: #fde68a;
}

[data-theme="dark"] .dose-badge.unit-price {
    background: #4c1d95;
    color: #c4b5fd;
}

[data-theme="dark"] .dose-badge.package {
    background: #312e81;
    color: #a5b4fc;
}

.item-price-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin: 0 10px;
}

.item-price {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
    white-space: nowrap;
}

.item-unit-price {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

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

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

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

.btn-secondary:hover {
    background-color: #475569;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #16a34a;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
    padding: 4px 8px;
    font-size: 0.8rem;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-add {
    background-color: var(--success-color);
    color: white;
    min-width: 70px;
    align-self: center;
}

.cart-items {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.empty-cart {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-style: italic;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    background: var(--surface-alt);
    transition: background-color 0.3s;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-description {
    font-weight: 500;
    margin-bottom: 2px;
    font-size: 0.95rem;
    word-break: break-word;
}

.cart-item-code {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.cart-item-dose {
    font-size: 0.75rem;
    color: var(--primary-color);
    margin-top: 2px;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.quantity-control button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    background: var(--surface);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.quantity-control button:hover {
    background: var(--border-color);
}

.quantity-control span {
    min-width: 30px;
    text-align: center;
    font-weight: 500;
}

.cart-item-price {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 80px;
    text-align: right;
}

.cart-summary {
    border-top: 2px solid var(--border-color);
    padding-top: 15px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 1rem;
}

.summary-row.total {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    border-top: 1px solid var(--border-color);
    margin-top: 10px;
    padding-top: 15px;
}

.cart-summary .btn {
    width: 48%;
    margin-top: 15px;
}

.cart-summary .btn:first-of-type {
    margin-right: 4%;
}

footer {
    margin-top: 30px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.disclaimer {
    margin-top: 10px;
    font-style: italic;
    color: var(--secondary-color);
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

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

.no-results {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-style: italic;
}

.results-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Item type badges */
.item-type-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 6px;
    vertical-align: middle;
}

.item-type-badge.pharmacy {
    background: #fef3c7;
    color: #92400e;
}

.item-type-badge.procedure {
    background: #dbeafe;
    color: #1e40af;
}

.item-type-badge.room {
    background: #dcfce7;
    color: #166534;
}

.item-type-badge.supply {
    background: #f3e8ff;
    color: #7c3aed;
}

.item-type-badge.other {
    background: #e5e7eb;
    color: #374151;
}

[data-theme="dark"] .item-type-badge.pharmacy {
    background: #78350f;
    color: #fde68a;
}

[data-theme="dark"] .item-type-badge.procedure {
    background: #1e3a5f;
    color: #93c5fd;
}

[data-theme="dark"] .item-type-badge.room {
    background: #14532d;
    color: #86efac;
}

[data-theme="dark"] .item-type-badge.supply {
    background: #4c1d95;
    color: #c4b5fd;
}

[data-theme="dark"] .item-type-badge.other {
    background: #374151;
    color: #d1d5db;
}

/* Print styles */
@media print {
    .search-section,
    .btn,
    .quantity-control button,
    #dark-mode-toggle {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    .container {
        max-width: 100%;
    }

    .cart-section {
        box-shadow: none;
        border: 1px solid #000;
        background: white;
    }

    .cart-item {
        border-color: #000;
        background: #f5f5f5;
    }

    header {
        background: white;
    }
}

/* Scrollbar styling */
.search-results::-webkit-scrollbar,
.cart-items::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track,
.cart-items::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb,
.cart-items::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover,
.cart-items::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}
