h1, h2, h3, h4, h5, h6, b, strong, th { font-weight: normal !important; }
@font-face {
    font-family: 'RTA';
    src: url('../../assets/rta.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --primary: #8e71f0;
    --primary-light: rgba(142, 113, 240, 0.08);
    --secondary: #a394ed;
    --accent: #eace67;
    --danger: #ff4757;
    --sidebar-bg: rgba(255, 255, 255, 0.8);
    --workspace-bg: #fdfdfd;
    --text-main: #2d3436;
    --text-muted: #636e72;
    --border-color: rgba(142, 113, 240, 0.15);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, button, input, textarea, select {
    font-family: 'RTA', 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--workspace-bg);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* Luxury Soft Background */
.background-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at 50% 50%, #ffffff 0%, #f0f0ff 100%);
}

.bg-blob {
    position: absolute;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(142, 113, 240, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(60px);
    animation: move 20s infinite alternate;
}

.blob1 { top: -10%; left: -10%; animation-delay: 0s; }
.blob2 { bottom: -10%; right: -10%; background: radial-gradient(circle, rgba(234, 206, 103, 0.08) 0%, transparent 70%); animation-delay: -5s; }

@keyframes move {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 30px) scale(1.1); }
}

/* Layout Structuring - Pillar Sidebar RTL Style */
.app-wrapper {
    display: flex;
    flex-direction: row; /* Sidebar on right (RTL), Main on left */
    height: 100vh;
    width: 100vw;
    position: relative;
    background: var(--workspace-bg);
    overflow: hidden;
    z-index: 1;
}

.main-layout {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Shared Header/Footer Bar Style */
.app-bar {
    height: 80px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 500;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.app-header {
    border-bottom: 1px solid var(--border-color);
}

.app-footer {
    border-top: 1px solid var(--border-color);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-area h1 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.action-group {
    display: flex;
    gap: 12px;
}

/* Quick Export Tabs Styling */
.quick-export-tabs {
    display: flex;
    background: rgba(142, 113, 240, 0.05);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    gap: 2px;
}

.btn-tab-export {
    height: 38px;
    padding: 0 16px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-tab-export:hover {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.btn-tab-export.highlight {
    background: var(--primary);
    color: #fff;
}

.btn-danger-header {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: #fff;
    color: var(--danger);
    border: 1px solid #fee2e2;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-danger-header:hover {
    background: #fef2f2;
    transform: rotate(-10deg) scale(1.05);
}

/* Footer Logic */
.footer-left, .footer-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.input-glass {
    background: rgba(142, 113, 240, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-size: 14px;
    width: 320px;
    outline: none;
    transition: var(--transition-fast);
    color: var(--text-main);
    font-weight: 500;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.input-glass:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.footer-stats {
    display: flex;
    gap: 12px;
}

.stat-badge {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-color);
    padding: 0 16px;
    height: 42px; /* Same as header buttons */
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-main);
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
    transition: var(--transition-fast);
}

.stat-badge:hover {
    background: #fff;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.stat-badge b {
    color: var(--primary);
    font-weight: 600;
    margin: 0 2px;
}

.stat-badge i {
    color: var(--primary);
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 300px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.sidebar-branding {
    height: 80px; /* Matches Header/Footer Height */
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-logo {
    height: 50px;
    width: auto;
    object-fit: contain;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #ffffff;
    padding: 12px;
    border-radius: var(--radius-lg);
    border: 1px solid #f1f5f9;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title h3 {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--text-main);
}

.header-title i { color: var(--primary); }

.badge {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary);
}

/* ===== BUTTONS ===== */
.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 400;
    color: var(--secondary);
    transition: var(--transition-fast);
}

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

.btn-primary-full {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow: 0 4px 12px rgba(142, 113, 240, 0.2);
    transition: var(--transition-fast);
}

.btn-primary-full:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(142, 113, 240, 0.3);
}

.btn-outline-full {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.btn-outline-full:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-primary-sidebar, .btn-danger-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 44px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
    border: none;
    color: #fff;
}

.btn-primary-sidebar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow: 0 6px 15px rgba(142, 113, 240, 0.2);
}

.btn-primary-sidebar:hover {
    filter: brightness(1.05);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(142, 113, 240, 0.3);
}

.btn-danger-sidebar {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fee2e2;
}

.btn-danger-sidebar:hover {
    background: var(--danger);
    color: #fff;
    transform: translateY(-2px);
}

/* ===== ICONS ===== */
.icon-sm { font-size: 16px; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; }
.icon-xs { font-size: 14px; width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; }
i[class*="fa-"] { line-height: 1; font-weight: 900 !important; }

.text-blue { color: #2563eb; }
.text-red { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-green { color: #10b981; }

/* ===== SETTINGS INPUTS ===== */
.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.label-tiny {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.dim-inputs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

.input-with-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-with-label label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.input-with-label input,
.input-wrapper input,
.input-minimal {
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    transition: var(--transition-fast);
    font-family: 'RTA', sans-serif;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.input-with-label input:focus,
.input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input { width: 100%; min-width: 0; }

.input-wrapper .unit {
    position: absolute;
    left: 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.input-minimal {
    border: none;
    background: #f8fafc;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    width: 100%;
    min-width: 0;
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.color-swatch input[type="color"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.color-preview-box {
    width: 100%;
    height: 100%;
}

/* Frame color dots */
.frame-colors {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.frame-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

.frame-dot:hover { transform: scale(1.1); }
.frame-dot.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

.frame-dot-none {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.frame-dot-none::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 45%, #f87171 45%, #f87171 55%, transparent 55%);
    border-radius: 50%;
}

/* Size select */
.size-select {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    outline: none;
    background: #fff;
    cursor: pointer;
    font-family: 'RTA', sans-serif;
    color: var(--text-main);
    transition: var(--transition-fast);
}

.size-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Direction buttons */
.dir-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.dir-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    font-size: 10px;
    font-weight: 400;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    background: #fff;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.dir-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Item controls panel */
.item-controls-panel {
    border-radius: var(--radius-lg);
    border: 1px solid rgba(142, 113, 240, 0.2);
    background: rgba(142, 113, 240, 0.03);
    overflow: hidden;
}

.ic-actions {
    display: flex;
    gap: 6px;
}

.ic-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-muted);
}

.ic-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.ic-btn.ic-delete:hover { background: var(--danger); border-color: var(--danger); }

/* Info mini */
.project-info-mini {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px dashed #e2e8f0;
}

.info-tag {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-tag .label { color: var(--text-muted); font-size: 11px; font-weight: 500; }
.info-tag .val {
    color: var(--primary);
    font-weight: 600;
    background: #fff;
    padding: 2px 6px;
    border-radius: 4px;
}

.border-top { border-top: 1px solid var(--border-color); padding-top: 16px; }

/* ===== WORKSPACE ===== */
.workspace {
    flex: 1;
    display: grid;
    place-items: safe center;
    position: relative;
    overflow: auto; /* Enable scrolling for large wall setups */
    background: radial-gradient(circle at 50% 50%, #ffffff 0%, #f0f0ff 100%);
}

#canvasViewport {
    transform-origin: center center;
    transition: transform 0.3s ease;
    padding: 40px; /* Gives a nice border around the board */
    box-sizing: content-box;
    flex-shrink: 0;
}

#wall {
    position: relative;
    background-color: #fdfdfd; /* Off-white wall color */
    border: 1px solid #e2e8f0;
    box-shadow: 
        0 20px 60px rgba(0,0,0,0.12),
        inset 0 0 0 1px rgba(255,255,255,0.8);
    /* Subtle wall texture (dots) */
    background-image: 
        radial-gradient(rgba(142, 113, 240, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}

#wall::after {
    content: "يمكنك سحب اللوحات وترتيبها هنا";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: #cbd5e1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-weight: 300;
}

#wall.empty::after {
    opacity: 1;
}

/* ===== WALL ITEMS ===== */
.wall-item {
    position: absolute;
    cursor: grab;
    pointer-events: auto;
    z-index: 20;
    transition: box-shadow 0.2s ease;
    user-select: none;
    background-color: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
}

.wall-item:active { cursor: grabbing; }

.wall-item.selected {
    box-shadow: 0 0 0 3px var(--primary), 0 10px 25px rgba(142, 113, 240, 0.3);
    z-index: 30 !important;
}

.wall-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wall-item .placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: #f8fafc;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 400;
    cursor: pointer;
    transition: var(--transition-fast);
}

.wall-item .placeholder:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.wall-item .placeholder i { font-size: 20px; }

/* Custom Frames */
.wall-item.frame-black { border: 2mm solid #111; padding: 2mm; box-sizing: content-box; }
.wall-item.frame-white { border: 2mm solid #fff; padding: 2mm; box-sizing: content-box; box-shadow: inset 0 0 0 1px #e2e8f0, 0 4px 15px rgba(0,0,0,0.1); }
.wall-item.frame-wood { border: 2mm solid #C19A6B; padding: 2mm; box-sizing: content-box; }

.frame-black { outline: 3px solid #111; }
.frame-white { outline: 3px solid #fff; box-shadow: 0 0 0 3px #fff, 0 4px 15px rgba(0,0,0,0.15); }
.frame-wood  { outline: 3px solid #C19A6B; }

/* ===== ZOOM CONTROLS ===== */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 6px 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.zoom-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 16px;
    transition: var(--transition-fast);
}

.zoom-btn:hover { background: var(--primary-light); color: var(--primary); }

.zoom-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    min-width: 36px;
    text-align: center;
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: #fff;
    width: 90%;
    max-width: 400px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 { font-size: 16px; font-weight: 400; }

.close-modal {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 20px;
}

.modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-primary-large {
    height: 44px;
    padding: 0 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
}

.btn-danger-large {
    height: 44px;
    padding: 0 24px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
}

.btn-ghost {
    height: 44px;
    padding: 0 20px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
}

.hidden { display: none; }

/* Custom Scrollbar */
.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

/* Spinner */
.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ===== ALIGN & DISTRIBUTE ===== */
.align-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.align-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 17px;
    transition: var(--transition-fast);
}

.align-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

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

/* Snap toggle */
.snap-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 9px;
    font-weight: 400;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.snap-label input[type="checkbox"] {
    width: 13px;
    height: 13px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Snap guide lines */
.snap-guide {
    position: absolute;
    pointer-events: none;
    z-index: 999;
    display: none;
}

.snap-guide-x {
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--primary);
    box-shadow: 0 0 6px rgba(142, 113, 240, 0.6);
}

.snap-guide-y {
    left: 0;
    right: 0;
    height: 1px;
    background: var(--primary);
    box-shadow: 0 0 6px rgba(142, 113, 240, 0.6);
}

@media (max-width: 900px) {
    .sidebar { width: 270px; }
}
