:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    /* Removed preview column */
    flex-grow: 1;
    overflow: hidden;
}

.security-banner {
    background: #ef4444;
    color: white;
    padding: 10px 20px;
    text-align: center;
    font-size: 0.9rem;
    z-index: 10000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.security-banner code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

/* Typography */
h1,
h2,
h3 {
    font-family: var(--font-heading);
    font-weight: 700;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: 0.2s;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: 0.2s;
    font-weight: 600;
}

.btn-success {
    background: var(--success);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: 0.2s;
    font-weight: 600;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: 0.2s;
    font-weight: 600;
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: 0.2s;
}

.btn-text:hover {
    color: var(--text);
    background: var(--border);
}

.btn-block {
    width: 100%;
}

/* Sidebar */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-container {
    margin-bottom: 15px;
}

.search-container input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
}

.product-list {
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
}

.product-item {
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: 0.2s;
    margin-bottom: 5px;
}

.product-item:hover {
    background: var(--background);
}

.product-item.active {
    background: var(--primary);
    color: white;
}

.product-item .symbol {
    font-weight: 700;
    font-size: 0.8rem;
    display: block;
    opacity: 0.8;
}

.product-item .name {
    font-size: 0.95rem;
}

.sidebar-footer {
    padding-top: 15px;
    border-top: 1px solid var(--border);
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
    background: #f1f5f9;
}

.view-hidden {
    display: none !important;
}

.data-table-container {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    overflow-x: auto;
}

.data-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.data-table th:hover {
    background: #f1f5f9;
}

.data-table tr:hover {
    background: #f8fafc;
}

.sort-icon {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 5px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.sort-asc .sort-icon {
    border-bottom: 4px solid var(--text-muted);
}

.sort-desc .sort-icon {
    border-top: 4px solid var(--text-muted);
}

.action-btn-group {
    display: flex;
    gap: 5px;
}

.btn-icon {
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
    cursor: pointer;
    color: var(--text-muted);
}

.btn-icon:hover {
    background: var(--background);
    color: var(--primary);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.product-info {
    display: flex;
    gap: 20px;
    flex-grow: 1;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.input-group input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    min-width: 200px;
}

.editor-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    /* Pozwala zawijać przyciski na mniejszych ekranach */
    align-items: center;
}

.editor-actions button {
    white-space: nowrap;
    /* Zapobiega łamaniu tekstu wewnątrz przycisków */
    flex-shrink: 0;
}

/* Sections */
.sections-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
}

.section-header {
    background: #fafafa;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    cursor: grab;
}

.section-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-controls {
    display: flex;
    gap: 10px;
}

.section-controls .btn-text {
    padding: 8px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.section-content {
    padding: 20px;
}

/* WYSIWYG Editor */
.wysiwyg-toolbar {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    background: #f8fafc;
    padding: 5px;
    border-radius: 4px;
}

.toolbar-btn {
    padding: 4px 8px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.toolbar-btn:hover {
    background: var(--background);
}

.toolbar-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.rich-text-editor {
    min-height: 100px;
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 4px;
}

/* Preview Panel */
.preview-panel {
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.preview-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-content-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    background: #eee;
}

.preview-content {
    background: white;
    min-height: 100%;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Login Page Styles */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    overflow: auto;
}

.login-container {
    background: var(--surface);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: 0.2s;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.error-message {
    background: #fef2f2;
    color: var(--danger);
    padding: 10px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 20px;
    border: 1px solid #fee2e2;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-content h3 {
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Sortable list/table styles */
.sort-handle {
    cursor: grab;
    color: var(--text-muted);
}

.list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.list-item input {
    flex-grow: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.params-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.params-table th {
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 8px;
    border-bottom: 2px solid var(--border);
}

.params-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.params-table input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.dragging-section,
.dragging-row,
.dragging-item {
    opacity: 0.4;
    border: 2px dashed var(--primary);
}

.sort-placeholder {
    opacity: 0;
}

/* Transitions */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Notifications */
.notification-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
}

.notification {
    background: var(--surface);
    padding: 12px 24px;
    border-radius: var(--radius);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    margin-top: 10px;
    border-left: 4px solid var(--primary);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-left-color: var(--success);
}

.notification.danger {
    border-left-color: var(--danger);
}