@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius: 12px;
    --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    line-height: 1.5;
}

.page-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    gap: 1rem;
}

.page-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.back-link {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--primary-color);
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    letter-spacing: -0.025em;
}

.page-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin: 0;
}

.content-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .controls {
        position: static;
        top: auto;
    }
}

.controls {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 1rem;
}

.info-box {
    background-color: #eff6ff;
    border: 1px solid #dbeafe;
    padding: 1rem;
    border-radius: calc(var(--radius) - 4px);
    margin-bottom: 1.5rem;
}

.info-box p {
    margin: 0.25rem 0;
    font-size: 0.85rem;
    color: #1e40af;
}

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.section-controls {
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.section-controls h4 {
    margin-top: 0;
    font-size: 1.1rem;
}

.part-item {
    background: #f1f5f9;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.part-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    margin-top: 0.75rem;
}

.part-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.color-input {
    height: 38px;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.color-input input {
    width: 150%;
    height: 150%;
    cursor: pointer;
    border: none;
    padding: 0;
    transform: translate(-10%, -10%);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    width: 100%;
    margin-bottom: 0.75rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

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

.btn-add {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.btn-add:hover {
    background-color: #d1fae5;
}

.btn-remove {
    width: 38px;
    height: 38px;
    padding: 0;
    margin: 0;
    background-color: #fee2e2;
    color: #991b1b;
    border-radius: 8px;
}

.btn-remove:hover:not(:disabled) {
    background-color: #fecaca;
}

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

.preview {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: auto;
}

.preview h2 {
    margin-top: 0;
    font-size: 1.25rem;
    align-self: flex-start;
    color: var(--text-muted);
}

#spielfeld {
    max-width: 100%;
    height: auto !important;
    border: 1px solid var(--border-color);
    background-color: white;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.form-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-section {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.input-description,
.input-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.submit-btn,
.compress-btn,
.download-btn,
.reset-btn {
    width: 100%;
    padding: 0.9rem;
    border-radius: 999px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.submit-btn,
.download-btn {
    background: linear-gradient(120deg, var(--primary-color), var(--primary-hover));
    color: #fff;
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.25);
}

.compress-btn {
    background: linear-gradient(135deg, #d42a2a 0%, #a24b4b 100%);
    color: #fff;
}

.reset-btn {
    border: 2px solid rgba(99, 102, 241, 0.4);
    background: transparent;
    color: var(--text-main);
}

.submit-btn:hover,
.download-btn:hover,
.compress-btn:hover,
.reset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
}

.status-container {
    margin-top: 1.5rem;
}

.loading,
.message {
    padding: 1rem;
    border-radius: 12px;
    font-weight: 500;
    text-align: center;
    border: 1px solid rgba(15, 23, 42, 0.1);
    display: none;
}

.loading.show,
.message.show {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
}

.message.success-message {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    color: #047857;
}

.message.error-message {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.4);
    color: #b91c1c;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fafc;
    margin-bottom: 1.5rem;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.quality-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.quality-btn {
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    font-weight: 600;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.quality-btn.selected {
    border-color: var(--primary-color);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
}

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

.custom-quality {
    display: none;
    margin-top: 0.5rem;
}

.custom-quality.show {
    display: block;
}

.slider-container {
    padding: 0.5rem 0;
}

.slider-value {
    margin-top: 0.5rem;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(135deg, #22c55e, #14b8a6);
    transition: width 0.3s ease;
}

.preview-card {
    margin-top: 18px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    padding: 14px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    font-weight: 600;
}

/* Image Comparison Slider Styles */
.img-comp-container {
    position: relative;
    width: 100%;
    border-radius: 14px;
    background: #f2f2f2;
    border: 1px solid #eaeaea;
    overflow: hidden;
    --slider-value: 50%;
}

.img-comp-container:not(.has-preview) {
    min-height: 400px;
}

.img-comp-container:not(.has-preview)::after {
    content: "Bildvorschau erscheint nach Komprimierung";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #777;
    font-size: 0.95rem;
    background: #f2f2f2;
    z-index: 1;
}

.img-comp-img {
    display: grid;
    width: 100%;
}

.img-comp-img img {
    grid-area: 1 / 1;
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.img-comp-img.img-comp-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--slider-value);
    overflow: hidden;
}

.img-comp-overlay {
    z-index: 1;
}

.img-comp-overlay::before {
    content: 'Komprimiert';
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(99, 102, 241, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 10;
    pointer-events: none;
}

.img-comp-container.has-preview .img-comp-img:first-child::before {
    content: 'Original';
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 10;
    pointer-events: none;
}

.img-comp-slider {
    position: absolute;
    z-index: 9;
    cursor: ew-resize;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border: 3px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.img-comp-slider:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.img-comp-slider::before,
.img-comp-slider::after {
    content: '';
    position: absolute;
    background: linear-gradient(to bottom,
        rgba(99, 102, 241, 0.8) 0%,
        rgba(99, 102, 241, 1) 50%,
        rgba(99, 102, 241, 0.8) 100%);
    width: 4px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.img-comp-slider::before {
    top: 100%;
    height: 200vh;
}

.img-comp-slider::after {
    bottom: 100%;
    height: 200vh;
}

.preview-subtext {
    margin-top: 10px;
    color: #666;
    font-size: 0.95rem;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-box {
    background: #f8fafc;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
    justify-content: center;
}

@media (max-width: 900px) {
    .services-grid {
        grid-template-columns: repeat(2, minmax(200px, 1fr));
    }
}

@media (max-width: 640px) {
    .services-grid {
        grid-template-columns: 1fr;
    }
}

.service-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.service-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

.service-button {
    display: inline-flex;
    background: linear-gradient(120deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-top: 1rem;
    margin-top: auto;
}

/* Datei Browser Styles */
.search-container {
    margin-bottom: 1.5rem;
}

.search-box {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text-main);
    font-family: inherit;
    transition: border-color 0.2s;
}

.search-box:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-results {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.breadcrumbs {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.breadcrumbs span {
    color: var(--text-muted);
}

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

.breadcrumbs a:hover {
    text-decoration: underline;
}

.file-browser {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s ease;
    border: 1px solid transparent;
}

.file-item:hover {
    background: var(--bg-color);
}

.file-item.folder {
    cursor: pointer;
    font-weight: 500;
}

.file-item.hidden {
    display: none;
}

.file-icon {
    font-size: 1.5rem;
    margin-right: 0.75rem;
    min-width: 2rem;
    text-align: center;
}

.file-name {
    flex: 1;
    color: var(--text-main);
}

.file-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-right: 1rem;
}

.btn-download {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

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

.nested-list {
    list-style: none;
    padding-left: 2rem;
    margin: 0.5rem 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.file-item.expanded > .nested-list {
    max-height: 5000px;
}

.folder-toggle {
    margin-right: 0.5rem;
    transition: transform 0.2s;
}

.file-item.expanded > .folder-toggle {
    transform: rotate(90deg);
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.error {
    padding: 1rem;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 0.5rem;
    color: #c00;
}

.pdf-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    animation: fadeIn 0.2s ease-out;
}

.pdf-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.pdf-overlay-content {
    width: 90%;
    height: 90%;
    max-width: 1200px;
    background: white;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pdf-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 8px 8px 0 0;
}

.pdf-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.pdf-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.pdf-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.pdf-iframe {
    flex: 1;
    border: none;
    border-radius: 0 0 8px 8px;
}

footer {
    text-align: center;
    color: var(--text-muted);
    margin-top: 3rem;
    letter-spacing: 0.3em;
    font-size: 0.8rem;
}

.tool-intro {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
  text-align: left;
}

.tool-intro h2 {
  margin: 0 0 6px 0;
  font-size: 0.95rem;
}

.tool-intro ol {
  margin: 0;
  padding-left: 18px;
  font-size: 0.95rem;
  color: #374151;
}

.tool-intro li {
  margin: 4px 0;
}

.tool-intro-note {
  margin: 8px 0 0 0;
  font-size: 0.85rem;
  color: #6b7280;
}
