/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #004FA6;
    --primary-hover: #003d80;
    --primary-light: rgba(0, 79, 166, 0.08);
    --primary-glow: rgba(0, 79, 166, 0.15);
    --secondary-color: #2c5282;
    --success-color: #48bb78;
    --error-color: #f56565;
    --border-color: #e2e8f0;
    --bg-color: #f7fafc;
    --text-color: #2d3748;
    --text-light: #718096;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header / Navbar */
.navbar {
    display: flex;
    align-items: center;
    margin-bottom: 3rem;
    padding: 1rem 0;
    border-bottom: 3px solid var(--primary-color);
}

.header-logo {
    height: 100px;
    object-fit: contain;
    flex-shrink: 0;
}

.navbar-center {
    flex: 1;
    text-align: center;
}

.navbar-center h1 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 0.15rem;
}

.navbar-center p {
    color: var(--text-light);
    font-size: 1rem;
}

/* Sections */
section {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

/* Template Selector */
.template-selector .radio-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.radio-card {
    display: block;
    padding: 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.radio-card:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
}

.radio-card input[type="radio"] {
    margin-right: 0.5rem;
}

.radio-card input[type="radio"]:checked + span {
    font-weight: bold;
    color: var(--primary-color);
}

/* Mode Selectors */
.mode-selectors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.mode-group .radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mode-group label {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-group label:hover {
    background-color: var(--bg-color);
}

.mode-group input[type="radio"] {
    margin-right: 0.75rem;
    cursor: pointer;
}

.mode-group input[type="radio"]:checked + span {
    font-weight: 600;
}

/* Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.required {
    color: var(--error-color);
    margin-left: 0.25rem;
}

.form-group input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Field sizes reflecting PDF importance */
.form-group.size-xl input {
    font-size: 1.6rem;
    font-weight: 700;
    padding: 1rem;
}

.form-group.size-lg input {
    font-size: 1.3rem;
    font-weight: 600;
    padding: 0.85rem;
}

.form-group.size-md input {
    font-size: 1rem;
    padding: 0.75rem;
}

.form-group.size-sm input {
    font-size: 0.9rem;
    padding: 0.6rem;
}

.form-group.centered input {
    text-align: center;
}

/* Inline field row (Gebinde + Liter side by side) */
.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* Editor + Preview Layout */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.preview-panel {
    position: sticky;
    top: 2rem;
}

.preview-container {
    position: relative;
    background: #cbd5e0;
    border-radius: 6px;
    overflow: hidden;
    padding: 1rem;
}

.preview-canvas {
    width: 100%;
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.preview-loading {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    z-index: 1;
}

.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-light);
    font-size: 0.95rem;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

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

.btn-secondary:hover:not(:disabled) {
    background-color: #1a4568;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.search-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 1rem;
}

.products-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-item {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.product-item:hover {
    background-color: var(--bg-color);
    border-color: var(--primary-color);
}

.product-item-info {
    flex: 1;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-delete {
    background: none;
    border: 1px solid transparent;
    color: var(--text-light);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-delete:hover {
    color: #dc3545;
    border-color: #dc3545;
    background-color: #fff5f5;
}

.artikelnummer {
    display: block;
    font-size: 0.875rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

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

.no-products {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

/* Alert */
.alert {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

.alert-error {
    background-color: var(--error-color);
    color: white;
}

/* Under Construction */
.under-construction {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
}

.under-construction h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

/* Login Screen */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-color);
}

.login-card {
    background: white;
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border-top: 4px solid var(--primary-color);
}

.brand-logo {
    height: 80px;
    margin-bottom: 1.25rem;
    object-fit: contain;
}

.login-card h1 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.login-card > p {
    color: var(--text-light);
    margin-bottom: 2rem;
}

.login-field {
    margin-bottom: 1.25rem;
    text-align: left;
}

.login-field label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.login-field input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.login-field input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.login-error {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.login-btn {
    width: 100%;
    margin-top: 0.5rem;
}


.btn-logout {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
}

.btn-logout:hover {
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* Responsive */
@media (max-width: 1024px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .preview-panel {
        position: static;
    }

    .preview-container {
        max-height: 600px;
        aspect-ratio: auto;
        height: 600px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    section {
        padding: 1.5rem;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
