:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #f1c40f;
    --text-color: #333;
    --bg-color: #f4f4f4;
    --white: #ffffff;
    --border-color: #ddd;
    --success-color: #27ae60;
    --danger-color: #c0392b;
    --header-bg: #fff;
    --card-bg: #fff;
    --footer-bg: #ffffff;
    --footer-text: #333333;
    --footer-link-color: #7f8c8d;
}

body.dark-mode {
    --primary-color: #3498db;
    --secondary-color: #ecf0f1;
    --accent-color: #f39c12;
    --text-color: #ecf0f1;
    --bg-color: #1a1a1a;
    --white: #2c3e50;
    --border-color: #444;
    --header-bg: #2c3e50;
    --card-bg: #34495e;
    --footer-bg: #2c3e50;
    --footer-text: #ecf0f1;
    --footer-link-color: #bdc3c7;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-image: url('tło2.jpeg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: var(--primary-color);
}

a:hover {
    text-decoration: underline;
}

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

/* Header */
.site-header {
    background-color: var(--header-bg);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    padding: 15px 0;
}

.header-inner {
    display: flex;
    flex-direction: column;
}

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

.site-logo {
    max-height: 50px;
}

.user-menu-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.cart-link-container {
    position: relative;
}

.cart-icon-link {
    color: var(--text-color);
    display: flex;
    align-items: center;
}

.cart-badge {
    background-color: var(--accent-color);
    color: #333;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.8em;
    font-weight: bold;
    position: absolute;
    top: -5px;
    right: -5px;
}

.user-auth-links {
    font-size: 0.9em;
}

.auth-btn {
    display: inline-block;
    padding: 5px 10px;
    margin-left: 5px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.auth-btn:hover {
    background-color: #2980b9;
    text-decoration: none;
}

.auth-btn.logout { background-color: var(--secondary-color); }
.auth-btn.register { background-color: var(--accent-color); color: #333; }

.header-bottom h1 {
    margin: 0;
    font-size: 1.5em;
    color: var(--secondary-color);
    text-align: center;
}

/* Main Layout */
.content-wrapper {
    display: flex;
    gap: 30px;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background-color: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.sidebar h3 {
    margin-top: 0;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 10px;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    margin-bottom: 8px;
}

.sidebar a {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    color: var(--text-color);
    border-radius: 4px;
}

.sidebar a:hover, .sidebar a.active {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
}

.sidebar .badge {
    background-color: rgba(0,0,0,0.1);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.8em;
}

.main-content {
    flex: 1;
}

/* Search Bar */
.search-bar-container form {
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

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

.btn-clear {
    background-color: var(--secondary-color);
    color: white;
    display: inline-flex;
    align-items: center;
    padding: 8px 15px;
    border-radius: 4px;
}

/* Product Grid (replaces products-grid) */
.products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.product-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    padding: 0; /* Reset padding if previously set on container */
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.product-image {
    height: 200px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-image.placeholder {
    color: #999;
    font-style: italic;
    background-color: #f9f9f9;
}

.product-title {
    font-size: 1.1em;
    margin: 15px 15px 5px 15px;
    font-weight: bold;
}

.product-description {
    padding: 0 15px;
    font-size: 0.9em;
    color: #777;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0 15px 10px 15px;
}

/* Internal product card layout (stock, form) */
.product-card form {
    padding: 0 15px 15px 15px;
    margin-top: auto;
}

.product-card > div[style*="font-size: 0.9em"] {
    padding: 0 15px;
}

/* Cart */
.cart-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.cart-table th, .cart-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    color: var(--text-color);
}

.cart-table th {
    background-color: var(--primary-color);
    color: white;
}

.cart-total {
    font-size: 1.4em;
    font-weight: bold;
    text-align: right;
    margin-top: 30px;
    color: var(--text-color);
    background-color: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.empty-cart {
    text-align: center;
    margin: 50px 0;
    font-size: 1.5em;
    padding: 40px;
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

/* Pagination */
.pagination {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 5px;
}

.pagination a, .pagination span {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
    color: var(--text-color);
}

.pagination a:hover {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
}

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

.pagination .disabled {
    color: #999;
    background-color: #eee;
    pointer-events: none;
}

/* Footer */
footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 40px 0 20px;
    margin-top: 50px;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    padding: 0 20px;
    text-align: center;
}

.footer-link {
    color: var(--footer-link-color);
}

/* Alerts */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

/* General Buttons */
.btn {
    display: inline-block;
    padding: 8px 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    text-align: center;
}

.btn:hover {
    background-color: #2980b9;
    text-decoration: none;
}

.white-bg-container {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-top: 20px;
    color: var(--text-color);
}

/* Responsive */
@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .content-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .user-menu-container {
        flex-direction: column;
    }
    
    .search-bar-container form {
        flex-direction: column;
    }
}

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--secondary-color);
    color: white;
    padding: 15px;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    transition: transform 0.3s ease-in-out;
}

.cookie-banner.hidden {
    transform: translateY(100%);
}

.cookie-banner p {
    margin: 0;
    font-size: 0.9em;
    max-width: 800px;
}

.cookie-banner .btn {
    background-color: var(--accent-color);
    color: #333;
    white-space: nowrap;
}

.cookie-banner .btn:hover {
    background-color: #f39c12;
}

/* AI Assistant - Modern Redesign */
#ai-widget-container {
    position: fixed;
    bottom: 100px; /* Wyżej, aby nie zasłaniała stopka */
    right: 30px;
    width: 350px;
    background-color: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: 1px solid rgba(255,255,255,0.1);
    font-family: 'Segoe UI', sans-serif;
}

#ai-widget-container.collapsed {
    height: 60px;
    width: 300px; /* Szerszy, aby zmieścić nazwę */
    bottom: 30px;
    border-radius: 30px;
}

.ai-chat-header {
    background: linear-gradient(135deg, var(--primary-color), #2980b9);
    color: white;
    padding: 0 20px;
    height: 60px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1.05em;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.ai-chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 450px;
    background-color: var(--bg-color);
}

#ai-widget-container.collapsed .ai-chat-body {
    display: none;
}

#ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

.ai-message {
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 85%;
    font-size: 0.95em;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    word-wrap: break-word;
}

.ai-message.ai {
    background-color: var(--white);
    color: var(--text-color);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0,0,0,0.05);
}

.ai-message.user {
    background: linear-gradient(135deg, var(--primary-color), #3498db);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-chat-input-area {
    padding: 15px;
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    gap: 10px;
    background-color: var(--card-bg);
    align-items: center;
}

.ai-chat-input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    background-color: var(--bg-color);
    color: var(--text-color);
    outline: none;
    transition: all 0.3s ease;
    font-size: 0.95em;
}

.ai-chat-input-area input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.ai-chat-input-area button {
    background: linear-gradient(135deg, var(--primary-color), #2980b9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-chat-input-area button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(52, 152, 219, 0.4);
}

.ai-chat-input-area button svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

/* AI Chevron Rotation */
#ai-chevron {
    transition: transform 0.3s ease;
}

#ai-widget-container:not(.collapsed) #ai-chevron {
    transform: rotate(180deg);
}

/* Loading Indicator */
.ai-message.loading {
    display: flex;
    gap: 3px;
    align-items: center;
    padding: 15px 18px; /* Slightly larger for dots */
}

.ai-message.loading span {
    width: 6px;
    height: 6px;
    background-color: var(--text-color);
    border-radius: 50%;
    animation: ai-blink 1.4s infinite both;
    opacity: 0.6;
}

.ai-message.loading span:nth-child(2) { animation-delay: 0.2s; }
.ai-message.loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-blink {
    0% { opacity: 0.2; transform: scale(0.8); }
    20% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0.2; transform: scale(0.8); }
}
