/* ========================================================================== */
/* REOS-PDF DESIGN SYSTEM & RESET                                             */
/* ========================================================================== */

:root { 
    --belfor-red: #E3000F; 
    --belfor-dark: #222222; 
    --bg-color: #f0f2f5; 
    --border: #ced4da; 
    --text-main: #333; 
    --card-size: 140px; 
}

* { 
    box-sizing: border-box; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
}

html, body { 
    margin: 0;
    padding: 0;
    background-color: var(--bg-color); 
    color: var(--text-main);
    width: 100vw;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========================================================================== */
/* HEADER DESIGN                                                              */
/* ========================================================================== */

header { 
    background: var(--belfor-dark); 
    color: white; 
    border-bottom: 4px solid var(--belfor-red); 
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    gap: 10px;
    width: 100%;
}

.header-title-wrapper h2 { 
    margin: 0; 
    font-size: 1.4rem; 
    letter-spacing: 0.5px; 
    color: white;
}

.header-title-wrapper .subtitle { 
    font-size: 11px; 
    opacity: 0.8; 
    color: #bbb;
}

.header-title-wrapper .highlight { 
    color: var(--belfor-red); 
}

.mode-btn {
    background: rgba(255,255,255,0.06);
    color: #aaa;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 6px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.mode-btn.active {
    background: var(--belfor-red);
    color: white;
    border-color: var(--belfor-red);
    box-shadow: 0 4px 12px rgba(227, 0, 15, 0.4);
}

/* ========================================================================== */
/* TOOLBAR & BUTTONS                                                          */
/* ========================================================================== */

.pdf-toolbar {
    display: flex;
    gap: 10px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    margin-bottom: 15px;
	  display: grid;
		width: 100%;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.pdf-grid{
		display: grid;
		width: 100%;
		grid-template-columns: repeat(2, 1fr);
		gap: 14px;
}
@media only screen and (max-width: 600px) {
	.pdf-toolbar {
    grid-template-columns: repeat(1, 1fr);
	}
	.pdf-grid{
		grid-template-columns: repeat(1, 1fr);
	}
}
.pdf-toolbar input{
		width: 100%;
}
.pdf-button { 
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    width: 100%;
}

button { 
    user-select: none; 
    cursor: pointer; 
    padding: 4px; 
    border: none; 
    border-radius: 6px; 
    font-weight: 600; 
    transition: all 0.2s; 
    font-size: 13px; 
    display: inline-flex; 
    align-items: center; 
    gap: 4px; 
    justify-content: center;
}

.btn-text { 
    display: inline-block; 
}

/* Button Variants */
.btn-primary { 
    background: var(--belfor-red); 
    color: white; 
    box-shadow: 0 2px 6px rgba(227, 0, 15, 0.25); 
}
.btn-primary:hover { 
    background: #c2000d; 
    transform: translateY(-1px); 
}

.btn-danger { 
    background: #dc3545; 
    color: white; 
}
.btn-danger:hover { 
    background: #c82333; 
}

.btn-outline { 
    background: #f8f9fa; 
    border: 1px solid var(--border); 
    color: #495057; 
}
.btn-outline:hover { 
    background: #e9ecef; 
}

.btn-outline.primary { 
    border-color: #0b509e; 
    color: #0b509e; 
    background: #e7f5ff; 
}
.btn-outline.primary:hover { 
    background: #d0ebff; 
}

/* Spinner Animation */
@keyframes belforSpin { 
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); } 
}

.belfor-spinner { 
    animation: belforSpin 1.5s ease-in-out infinite; 
    width: 96px; 
    height: 96px; 
    filter: drop-shadow(0px 6px 12px rgba(0,0,0,0.15)); 
}

/* ========================================================================== */
/* DRAG & DROP ARBEITSFLÄCHE (DROP ZONE)                                      */
/* ========================================================================== */

#pdf-drop-zone {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    height: 100%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: all 0.25s ease-in-out;
    position: relative;
}

#pdf-drop-zone.drag-over {
    border-color: var(--belfor-red) !important;
    background-color: #fff5f5 !important;
    transform: scale(0.995);
    box-shadow: inset 0 0 20px rgba(227, 0, 15, 0.1);
}

/* ========================================================================== */
/* PDF KARTEN & GRID                                                          */
/* ========================================================================== */

#pdf-tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-size), 1fr));
    gap: 15px;
}

.pdf-page-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    cursor: grab;
    position: relative;
}

.pdf-page-card:hover {
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.pdf-page-card:active {
    cursor: grabbing;
}

/* Drag-States für die Karten */
.pdf-page-card.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}

.pdf-page-card.drag-over-card {
    border-top: 3px solid var(--belfor-red);
}

/* Design, wenn eine Karte über eine andere gezogen wird */
.drag-over {
    border: 2px dashed var(--belfor-red) !important;
    background: #fff5f5;
    transform: scale(1.02);
} 

.pdf-page-img-container {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    margin-bottom: 10px;
    width: 100%;
    aspect-ratio: 1 / 1.414; /* Zwingt den Container in die typische A4-Proportion */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pdf-page-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.pdf-page-info {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-align: center;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.pdf-page-actions {
    display: flex !important; /* Überschreibt das starre Grid */
    justify-content: space-between;
    gap: 4px;
    width: 100%;
}

.pdf-page-actions button,
.pdf-page-card button {
    flex: 1;
    padding: 6px 4px !important;
    min-width: 0 !important;
    white-space: normal;
    line-height: 1.2;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pdf-order-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 30;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    cursor: grab;
}

.pdf-mobile-drag-handle {
    display: none;
}

/* ========================================================================== */
/* MODAL / OVERLAY & PDF VORSCHAU LAYOUT                                      */
/* ========================================================================== */

.modal-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.6); 
    display: none; 
    align-items: center; 
    justify-content: center; 
    z-index: 1000; 
    backdrop-filter: blur(3px); 
    flex-direction: column; 
}

.modal-overlay.active { 
    display: flex; 
}

.modal-overlay.dark-overlay { 
    background: rgba(0,0,0,0.92); 
    z-index: 10002; 
}

.pdf-overlay-wrapper { 
    display: flex; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh; 
    z-index: 9999; 
    background: #525659; 
    flex-direction: row; 
    margin: 0; 
    padding: 0; 
}

.pdf-overlay-canvas-container { 
    flex-grow: 1; 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    overflow-y: auto; 
    padding: 20px; 
    gap: 15px; 
}

.pdf-overlay-sidebar { 
    width: 320px; 
    background: #f8f9fa; 
    padding: 20px; 
    box-shadow: -2px 0 5px rgba(0,0,0,0.1); 
    overflow-y: auto; 
}

.pdf-sidebar-card { 
    background: white; 
    padding: 15px; 
    border-radius: 8px; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); 
}
textarea::-webkit-resizer {
  background-color: #f8f9fa;
  border-top: 1px solid #ced4da;
  border-left: 1px solid #ced4da;
	border-radius:1px; 
}

/* ========================================================================== */
/* MEDIA QUERIES (MOBILE & TOUCH DEVICES)                                     */
/* ========================================================================== */

/* Touch-Devices (Smartphones, Tablets) */
@media (pointer: coarse) {
    .pdf-page-card {
        user-select: none;
        -webkit-user-select: none;
        -webkit-user-drag: none;
    }

    .pdf-order-badge {
        touch-action: none;
        user-select: none;
        -webkit-user-select: none;
    }

    .pdf-mobile-drag-handle {
        display: flex;
        z-index: 20;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        background: #ccc;
        color: white;
        font-size: 24px;
        font-weight: bold;
        box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        touch-action: none;
    }

    .pdf-page-card.mobile-dragging {
        opacity: 0.65;
        transform: scale(1.03);
        outline: 3px solid #0b509e;
    }

    .pdf-page-card.mobile-drag-over {
        outline: 3px dashed #0b509e;
        background: #e7f5ff;
    }
}

/* Kleine Bildschirme (Smartphones) */
@media (max-width: 768px) {
    .pdf-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-title-wrapper h2 { 
        font-size: 1rem; 
        text-align: center; 
    }
    
    .btn-text { 
        display: none; 
    }
}
