:root {
    --primary: #1fa37a;
    --primary-dark: #178f68;
    --primary-light: #4fd4a8;
    --secondary: #ff3d00;
    --text: #222;
    --text-light: #666;
    --bg: #f9fafb;
    --white: #fff;
    --border: #e0e0e0;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 24px rgba(31,163,122,0.15);
}

[data-theme="dark"] {
    --text: #e0e0e0;
    --text-light: #b0b0b0;
    --bg: #1a1a1a;
    --white: #2a2a2a;
    --border: #444;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 24px rgba(31,163,122,0.3);
}

body {
    background: var(--bg);
    color: var(--text);
    transition: all 0.3s ease;
}

/* Animation */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 8px 24px rgba(255,61,0,0.4); }
    50% { box-shadow: 0 8px 32px rgba(255,61,0,0.6); }
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Container */
.med-container {
    padding: 1rem 5% 3rem;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeInUp 0.6s ease-out;
}

/* Header */
.med-header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.med-header::after {
    content: '';
    position: absolute;
    bottom: -1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 2px;
}

.med-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    font-family: "Bebas Neue", sans-serif;
    letter-spacing: 1px;
}

.med-header p {
    color: var(--text-light);
    font-size: 1.125rem;
    margin-bottom: 2rem;
}

/* Search Bar */
.search-bar {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    background: var(--white);
    padding: 0.5rem;
    border-radius: 50px;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    transition: all 0.3s;
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.search-bar input {
    flex: 1;
    border: none;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    border-radius: 50px;
    outline: none;
    background: transparent;
    color: var(--text);
}

.search-bar input::placeholder {
    color: var(--text-light);
    opacity: 0.6;
}

.search-bar button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(31,163,122,0.3);
}

.search-bar button:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 16px rgba(31,163,122,0.4);
}

.search-bar button:active {
    transform: scale(0.95);
}

/* Filter Section */
.filter-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.filter-chips {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex: 1;
}

.filter-chip {
    padding: 0.625rem 1.25rem;
    border: 2px solid var(--border);
    background: var(--white);
    color: var(--text);
    border-radius: 25px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.filter-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.sort-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 25px;
    border: 2px solid var(--border);
}

.sort-section label {
    color: var(--text-light);
}

.sort-section select {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    padding: 0.25rem;
}

/* Medicine Grid */
.med-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Medicine Card */
.med-card {
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.4s;
    display: flex;
    flex-direction: column;
    border: 2px solid transparent;
    position: relative;
}

.med-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s;
}

.med-card:hover::before {
    transform: scaleX(1);
}

.med-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-hover);
    border-color: rgba(31,163,122,0.2);
}

.med-image {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, #f0f7f4 0%, #e8f5f0 100%);
}

[data-theme="dark"] .med-image {
    background: linear-gradient(135deg, #2a2a2a 0%, #222 100%);
}

.med-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s;
}

.med-card:hover .med-image img {
    transform: scale(1.1) rotate(2deg);
}

.med-image .category {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s;
}

[data-theme="dark"] .med-image .category {
    background: rgba(42,42,42,0.95);
    color: var(--primary-light);
}

.med-card:hover .med-image .category {
    transform: scale(1.1);
}

.med-info {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.med-info h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    transition: color 0.3s;
}

.med-card:hover .med-info h3 {
    color: var(--primary);
}

.med-info p {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    flex: 1;
    line-height: 1.6;
}

.med-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.med-footer .price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    font-family: "Bebas Neue", sans-serif;
    letter-spacing: 1px;
}

.btn-add {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.btn-add:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(31,163,122,0.3);
}

.btn-add:active {
    transform: translateY(0) scale(0.98);
}

/* Cart Sidebar */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    max-width: 90vw;
    height: 100%;
    background: var(--white);
    box-shadow: -5px 0 25px rgba(0,0,0,0.15);
    z-index: 2000;
    transition: right 0.4s;
    display: flex;
    flex-direction: column;
}

.cart-sidebar.active {
    right: 0;
}

.cart-header {
    padding: 1.5rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(31,163,122,0.05) 0%, rgba(31,163,122,0.1) 100%);
}

.cart-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: "Bebas Neue", sans-serif;
    letter-spacing: 1px;
}

#closeCart {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

#closeCart:hover {
    color: var(--primary);
    background: rgba(31,163,122,0.1);
    transform: rotate(90deg);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.item-info h4 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.item-info p {
    color: var(--text-light);
    font-size: 0.875rem;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.item-actions button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--white);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.item-actions button:hover {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.item-actions .btn-remove {
    margin-left: auto;
    border-color: var(--border);
    color: var(--text-light);
}

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

.cart-footer {
    padding: 1.5rem;
    border-top: 2px solid var(--border);
    background: var(--bg);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    font-family: "Bebas Neue", sans-serif;
    letter-spacing: 1px;
}

.cart-footer .btn-primary {
    width: 100%;
    padding: 1rem;
}

/* Floating Cart Button */
.cart-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--secondary) 0%, #d63400 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(255,61,0,0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    animation: pulse 2s ease-in-out infinite;
}

.cart-toggle:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 12px 32px rgba(255,61,0,0.5);
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: white;
    color: var(--secondary);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--secondary);
    animation: bounce 0.5s ease;
}

.loading, .no-results, .error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem;
    color: var(--text-light);
    font-size: 1.125rem;
}

/* Responsiveness */
@media (max-width: 768px) {
    .med-container { padding: 1rem 4% 2rem; }
    .med-header h1 { font-size: 2rem; }
    .med-grid { 
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1.25rem;
    }
    .cart-sidebar { width: 100%; right: -100%; }
    .cart-toggle { width: 56px; height: 56px; bottom: 1.5rem; right: 1.5rem; }
    .filter-section { flex-direction: column; align-items: stretch; }
    .filter-chips { justify-content: center; }
    .filter-chip { font-size: 0.8rem; padding: 0.5rem 1rem; }
}

@media (max-width: 480px) {
    .med-grid { grid-template-columns: 1fr; }
    .search-bar { max-width: 100%; }
    .filter-chip { font-size: 0.75rem; padding: 0.4rem 0.8rem; }
    .filter-chip i { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}