:root {
    --bg-color: #f4f4f4;
    --surface-color: #ffffff;
    --text-main: #000000;
    --text-muted: #666666;
    --accent-color: #000000;
    --border-color: #e0e0e0;
    --danger-color: #e53935;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.1);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.15);
    
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden; /* App like feel, no page scroll */
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: row;
}

/* BUTTONS */
button {
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    font-size: 1.2rem;
}

.icon-btn:active {
    transform: scale(0.92);
}

.primary-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-color);
    color: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.primary-btn:active {
    transform: scale(0.98);
}

.danger-btn {
    width: 100%;
    padding: 14px;
    background: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    border-radius: var(--radius-md);
}

/* HEADER */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--surface-color);
    box-shadow: var(--shadow-sm);
    z-index: 10;
    position: relative;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.logo span {
    font-weight: 300;
}

/* PAGES */
.page {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* MAIN PAGE */
#page1 {
    position: relative;
    flex: 1;
    overflow: hidden;
    z-index: 1;
    transition: flex 0.4s;
}

.kroki-container {
    flex: 1;
    position: relative;
    overflow: auto; 
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px; /* Azaltıldı, daha büyük harita için */
    background: #e9e9e9;
}

.kroki-wrapper {
    position: relative;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.placeholder-text {
    color: var(--text-muted);
    font-weight: 400;
    padding: 20px;
    text-align: center;
}

#kroki-img {
    max-width: 100%;
    max-height: calc(100vh - 120px); /* Ekranı olabildiğince doldursun */
    object-fit: contain;
    border-radius: var(--radius-md);
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

/* DRAWING AREA (SVG OVERLAY) */
.drawing-area {
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none; /* View mode default */
}

/* Polygons */
.zone-polygon {
    fill: rgba(0, 0, 0, 0.2);
    stroke: var(--accent-color);
    stroke-width: 2;
    stroke-linejoin: round;
    cursor: pointer;
    transition: fill 0.2s ease;
    pointer-events: auto; /* Always clickable */
}

.zone-polygon:hover {
    fill: rgba(0, 0, 0, 0.4);
}

.zone-polygon.selected {
    fill: rgba(0, 0, 0, 0.6);
    stroke: #ffffff;
    stroke-width: 3;
    stroke-dasharray: 5,5;
}

/* Drawing Mode Classes */
.mode-drawing .drawing-area {
    pointer-events: auto;
    cursor: crosshair;
}

.mode-drawing .zone-polygon {
    pointer-events: none; /* Don't interact with existing zones while drawing */
}

.drawing-point {
    fill: var(--accent-color);
    stroke: #ffffff;
    stroke-width: 2;
}

.drawing-line {
    stroke: var(--accent-color);
    stroke-width: 2;
    stroke-dasharray: 4,4;
}


/* SIDEBAR */
.sidebar {
    position: relative;
    width: 320px;
    height: 100%;
    background: var(--surface-color);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    margin-left: -320px; /* Kapalıyken solda gizli */
    flex-shrink: 0;
    transition: margin-left 0.4s cubic-bezier(0.175, 0.885, 0.32, 1);
}

.sidebar.open {
    margin-left: 0; /* Açılınca ortaya çıkar ve haritayı iter */
}

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

.sidebar-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* DASHBOARD STATS CARDS */
.stat-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--accent-color);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--accent-color);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
}

.stat-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}


.setting-group {
    margin-bottom: 30px;
}

.setting-group h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.upload-btn {
    display: block;
    width: 100%;
    padding: 15px;
    background: var(--bg-color);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    transition: var(--transition);
}

.upload-btn:hover {
    border-color: var(--accent-color);
    background: #ebebeb;
}

.mode-switch {
    display: flex;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    padding: 4px;
}

.mode-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    color: var(--text-muted);
}

.mode-btn.active {
    background: var(--surface-color);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.instructions {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
    background: #e8f4fd;
    padding: 10px;
    border-radius: 8px;
    color: #0277bd;
}

/* DETAIL PAGE (Page 2) */
.panel-page {
    position: relative;
    z-index: 20;
    background: transparent;
    width: 360px; /* 320 container + 40 margin */
    margin-right: -360px; /* Kapalıyken sağda gizli */
    flex-shrink: 0;
    transition: margin-right 0.3s ease;
}

.panel-page.open {
    margin-right: 0; /* Açılınca haritayı sola iter */
}

.panel-container {
    width: 320px; /* Biraz daha küçük */
    max-width: calc(100% - 40px);
    height: auto;
    max-height: 90vh;
    margin: 20px; /* Kenarlardan boşluk bırakarak yüzen pencere görünümü */
    border-radius: var(--radius-lg);
    background: var(--surface-color);
    box-shadow: var(--shadow-lg), -5px 5px 20px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    pointer-events: auto; /* Pencerenin kendisine tıklanabilmesi için */
}

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

.panel-content {
    padding: 30px 20px;
    flex: 1;
    overflow-y: auto;
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    background: var(--bg-color);
    transition: var(--transition);
    outline: none;
}

.input-group input:focus {
    border-color: var(--accent-color);
    background: var(--surface-color);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

/* ZOOM CONTROLS */
.zoom-controls {
    position: absolute;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
}

/* Panning cursors */
.mode-view .kroki-container {
    cursor: grab;
}
.mode-view .kroki-container:active {
    cursor: grabbing;
}

.kroki-wrapper {
    transform-origin: center center;
    will-change: transform;
}
.kroki-wrapper.smooth-transform {
    transition: transform 0.3s ease-out;
}

/* FLOOR LIST */
.floor-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.floor-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.floor-item:hover {
    border-color: var(--accent-color);
}

.floor-item.active {
    background: var(--surface-color);
    border-color: var(--accent-color);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.floor-item .floor-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.floor-item .delete-floor-btn {
    color: var(--danger-color);
    padding: 5px;
    font-size: 1.1rem;
    opacity: 0.5;
}

.floor-item .delete-floor-btn:hover {
    opacity: 1;
}

/* UTILS */
.hidden {
    display: none !important;
}

/* DYNAMIC ITEMS */
.dynamic-item-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.dynamic-item-row input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
    font-size: 1rem;
    min-width: 0; /* Prevent flex overflow */
}

.remove-item-btn {
    background: transparent;
    color: var(--danger-color);
    border: none;
    cursor: pointer;
    padding: 0 5px;
    font-size: 1.2rem;
}

.zone-items-list .info-item-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.zone-items-list .info-item-row:last-child {
    border-bottom: none;
}
.zone-items-list .info-item-name {
    font-weight: 500;
    color: var(--text-muted);
}
.zone-items-list .info-item-val {
    font-weight: 700;
    color: var(--text-main);
}

/* SEARCH & TOOLTIP & EXPORT */
#search-input:focus {
    border-color: var(--accent-color) !important;
    box-shadow: var(--shadow-sm);
    background: var(--surface-color) !important;
}

.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    transform: translate(-50%, -100%);
    margin-top: -15px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tooltip:not(.hidden) {
    opacity: 1;
}

.zone-polygon.zone-dimmed {
    opacity: 0.15;
}

.zone-polygon.zone-highlight {
    stroke: #FFEB3B !important;
    stroke-width: 4px !important;
    filter: drop-shadow(0 0 5px rgba(255,235,59,0.8));
    opacity: 1;
}

/* MODAL */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal.hidden {
    display: none !important;
}
.modal-content {
    background: var(--surface-color);
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}
.modal-body {
    padding: 20px;
    line-height: 1.6;
}
.modal-body ol {
    padding-left: 20px;
}
.modal-body li {
    margin-bottom: 15px;
}

/* --- NEW MODULES --- */
/* LOGIN OVERLAY */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}
.login-overlay.hidden { display: none !important; }
.login-box {
    background: var(--surface-color);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 400px;
    text-align: center;
}
.login-box h2 {
    margin-bottom: 30px;
    font-size: 1.8rem;
    font-weight: 800;
}
.login-box h2 span { font-weight: 300; }
.login-box .input-group { text-align: left; }
.error-text { color: var(--danger-color); font-size: 0.9rem; margin-top: 10px; font-weight: 600; }

/* HUB SCREEN */
.hub-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}
.hub-screen.hidden { display: none !important; }
.hub-header { text-align: center; margin-bottom: 50px; }
.hub-header h2 { font-size: 2.5rem; margin-bottom: 10px; }
.hub-header p { color: var(--text-muted); font-size: 1.1rem; }
.hub-cards {
    display: flex;
    gap: 30px;
    width: 90%;
    max-width: 900px;
}
.hub-card {
    flex: 1;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: 2px solid transparent;
}
.hub-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color);
}
.hub-card i {
    font-size: 4rem;
    color: var(--accent-color);
    margin-bottom: 20px;
}
.hub-card h3 { font-size: 1.5rem; margin-bottom: 15px; }
.hub-card p { color: var(--text-muted); }

/* PRINT SECTION */
#print-section {
    width: 100vw;
    height: 100vh;
}
.print-template {
    width: 210mm; /* A4 width */
    height: 297mm; /* A4 height */
    padding: 20px;
    background: white;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
    transform: scale(0.6); /* Preview scale */
    transform-origin: top center;
    /* transition: all 0.3s ease; */ /* Removed to avoid weird sizing delays */
}

/* Base Scaling Factor Variables */
.size-a4.portrait.layout-1 { --s: 1.4; }
.size-a4.portrait.layout-2 { --s: 1.1; }
.size-a4.landscape.layout-1 { --s: 1.3; }
.size-a4.landscape.layout-2 { --s: 1.1; }
.size-a5.portrait.layout-1 { --s: 0.95; }
.size-a5.portrait.layout-2 { --s: 0.75; }
.size-a5.landscape.layout-1 { --s: 0.9; }
.size-a5.landscape.layout-2 { --s: 0.75; }

/* A4 Portrait */
.print-template.size-a4.portrait {
    width: 210mm;
    height: 297mm;
    flex-direction: column;
}
/* A4 Landscape */
.print-template.size-a4.landscape {
    width: 297mm;
    height: 210mm;
    flex-direction: row;
}
/* A5 Portrait */
.print-template.size-a5.portrait {
    width: 148mm;
    height: 210mm;
    flex-direction: column;
}
/* A5 Landscape */
.print-template.size-a5.landscape {
    width: 210mm;
    height: 148mm;
    flex-direction: row;
}

/* Layout Alignments */
.print-template.layout-2 {
    justify-content: center;
    gap: 12%; /* Perfect spacing for side-by-side or stacked */
}

.fiyat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Fiyatlık Template Styles */
#template-fiyatlik .fiyat-ust-yazi {
    font-size: calc(80px * var(--s, 1));
    font-weight: 400; /* Ince olacak */
    text-align: center;
    color: #1a1a1a;
    letter-spacing: -2px;
    margin-bottom: calc(30px * var(--s, 1));
}
#template-fiyatlik .fiyat-container {
    display: flex;
    align-items: flex-end; /* Align bottoms */
    justify-content: center;
    margin-bottom: calc(10px * var(--s, 1));
}
#template-fiyatlik .fiyat-tam {
    font-size: calc(280px * var(--s, 1)); /* Big number */
    font-weight: 800;
    line-height: 0.8;
    letter-spacing: -15px;
    color: #1a1a1a;
}
#template-fiyatlik .fiyat-sag {
    display: flex;
    flex-direction: row; /* Yan yana */
    align-items: baseline; /* Alt hizalama */
    justify-content: flex-start;
    margin-left: calc(15px * var(--s, 1));
    padding-bottom: calc(5px * var(--s, 1)); /* visual alignment tweak so they sit on 129 baseline */
}
#template-fiyatlik .fiyat-kurus {
    font-size: calc(90px * var(--s, 1)); /* Kuruş küçük ve ince */
    font-weight: 400;
    line-height: 1;
    letter-spacing: -2px;
    color: #1a1a1a;
}
#template-fiyatlik .fiyat-para {
    font-size: calc(60px * var(--s, 1)); /* Yanında küçük tl */
    font-weight: 500;
    line-height: 1;
    color: #1a1a1a;
    margin-top: 0;
    margin-left: calc(15px * var(--s, 1));
    text-align: left;
}
#template-fiyatlik .fiyat-alt-yazi {
    font-size: calc(26px * var(--s, 1));
    font-weight: 500;
    color: #1a1a1a;
    text-align: center;
    letter-spacing: 1px;
    margin-top: calc(20px * var(--s, 1));
}

/* MEDIA PRINT */
@media print {
    body {
        visibility: hidden;
        background: white;
    }
    #print-section, #print-section * {
        visibility: hidden;
    }
    .print-preview-wrapper {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        overflow: visible !important;
        width: 100% !important;
        height: 100% !important;
    }
    .print-preview-area {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: 100% !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .print-template:not(.hidden) {
        visibility: visible !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        transform: scale(1) !important; /* Reset scale for actual printing */
        page-break-after: always;
        margin: 0 !important;
        border: none !important;
    }
    .print-template.size-a4.portrait { width: 210mm !important; height: 297mm !important; }
    .print-template.size-a4.landscape { width: 297mm !important; height: 210mm !important; }
    .print-template.size-a5.portrait { width: 148mm !important; height: 210mm !important; }
    .print-template.size-a5.landscape { width: 210mm !important; height: 148mm !important; }

    @page { size: auto; margin: 0; }
    @page :first { margin: 0; }
    .print-template:not(.hidden) * {
        visibility: visible !important;
    }
}
