:root {
    --bg-dark: #F2F3F5; /* Main workspace background */
    --bg-panel: #FFFFFF; /* Sidebar panels background */
    --border-color: #E2E5E9; /* Soft grey borders */
    --text-primary: #0E1318; /* Near black dark text */
    --text-secondary: #5E6D7E; /* Soft steel text */
    --accent-color: #7D2AE8; /* Canva Purple */
    --accent-color-hover: #5A1EAA;
    --danger-color: #E03545;
    --danger-color-hover: #C22230;
    --canvas-bg: #FFFFFF;
    --btn-bg: #F7F9FA; /* Off-white grey button default */
    --btn-bg-hover: #E2E5E9; 
    --glass-blur: none;
}

@font-face {
    font-family: 'Chilanka';
    src: url('../Fonts/Chilanka.ttf') format('truetype');
}
@font-face {
    font-family: 'Kalyani';
    src: url('../Fonts/Kalyani.ttf') format('truetype');
}
@font-face {
    font-family: 'Thoolika';
    src: url('../Fonts/Thoolika.ttf') format('truetype');
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    display: flex;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Glassmorphism Panels -> Converted to Flat Panels */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
}

/* Top Navbar */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: linear-gradient(90deg, #00C4CC, #7D2AE8);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 10;
    color: #FFFFFF; /* Force white text over gradient */
}

/* Force elements inside top bar to contrast gracefully against the gradient */
.top-nav .icon-btn { color: #FFFFFF; }
.top-nav .icon-btn:hover { background: rgba(255, 255, 255, 0.2); }
.top-nav .divider { background: rgba(255, 255, 255, 0.3); }
.top-nav .btn-primary { 
    background: #FFFFFF; 
    color: var(--accent-color); 
    box-shadow: none; 
}
.top-nav .btn-primary:hover { 
    background: #F7F9FA; 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15); 
}

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

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #FFFFFF;
    animation: titleFloat 3s ease-in-out infinite;
}

@keyframes titleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.animate-spin {
    animation: rotation 2s infinite linear;
    display: inline-block;
}

@keyframes rotation {
    from { transform: rotate(0deg); }
    to { transform: rotate(359deg); }
}

.neon-icon {
    display: inline-block; /* Crucial: transforms do not work on inline elements like span */
    color: #FFFFFF;
    font-size: 1.5rem;
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { 
        text-shadow: 0 0 5px rgba(255,255,255,0.2);
        transform: scale(1);
    }
    50% { 
        text-shadow: 0 0 15px rgba(255,255,255,0.8);
        transform: scale(1.1) rotate(5deg);
    }
}

.save-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    margin-left: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

.save-status.saving {
    background: rgba(0, 0, 0, 0.1);
}

.save-status.error {
    background: rgba(224, 53, 69, 0.2);
    color: #ffdce0;
}

.save-status .material-icons {
    font-size: 1rem;
}

.save-status.saving .material-icons {
    animation: rotation 1.5s infinite linear;
}

.status-text {
    white-space: nowrap;
}

.nav-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

/* Core Buttons */
button {
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    transition: all 0.15s ease-in-out;
}

.icon-btn {
    background: transparent;
    color: var(--text-primary);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}
.icon-btn:hover { background: var(--btn-bg-hover); }
.icon-btn.disabled { color: var(--text-secondary); cursor: not-allowed; opacity: 0.5; }

.btn-primary {
    background: var(--accent-color);
    color: white;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
}
.btn-primary:hover {
    background: var(--accent-color-hover);
}

.btn-danger {
    background: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    padding: 9px 19px;
    font-size: 0.9rem;
    font-weight: 600;
}
.btn-danger:hover {
    background: var(--danger-color);
    color: white;
}

.ui-select {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}
.ui-select option { background: var(--bg-panel); color: var(--text-primary); }
.full-width { width: 100%; }

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

.icon-btn-text {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 0.85rem;
    border: none;
    border-radius: 4px;
}
.icon-btn-text:hover { background: var(--btn-bg-hover); }
.icon-btn-text .material-icons { font-size: 1.1rem; }
.text-danger { color: var(--danger-color); }
.btn-danger.outline { background: transparent; border: 1px solid var(--danger-color); color: var(--danger-color); box-shadow: none; }
.btn-danger.outline:hover { background: rgba(224, 53, 69, 0.1); }


/* Main Workspace */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-dark);
}

/* Sidebars Base */
.sidebar {
    background: var(--bg-panel);
    padding: 24px;
    display: flex;
    flex-direction: column;
    z-index: 5;
    overflow-y: auto;
    /* Soft material shadow */
    box-shadow: 0 0 15px rgba(0,0,0,0.03); 
}
.left-sidebar { border-right: 1px solid var(--border-color); }
.right-sidebar { border-left: 1px solid var(--border-color); }

/* Compact Settings */
.sidebar.compact { width: 220px; padding: 20px 16px; }
.sidebar.compact-right { width: 260px; padding: 20px 16px; }
.sidebar-divider { border: 0; border-top: 1px solid var(--border-color); margin: 16px 0; }
.panel-subtitle { font-size: 0.75rem; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; font-weight: 700; }

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
}
.submenu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
}
.tool-btn {
    background: var(--btn-bg);
    color: var(--text-primary);
    width: 100%;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
}
.tool-btn .material-icons { font-size: 1.3rem; }
.tool-btn:hover { background: var(--btn-bg-hover); color: var(--accent-color); }
.tool-btn.active {
    background: rgba(125, 42, 232, 0.1); /* Canva Purple 10% opacity */
    color: var(--accent-color);
    border-color: rgba(125, 42, 232, 0.2);
}

/* Canvas Area */
.workspace-canvas-area {
    flex: 1;
    display: flex;
    overflow: auto;
    position: relative;
    background-color: var(--bg-dark);
    padding: 60px; /* Generous padding for breathing room */
}

.canvas-wrapper {
    margin: auto; /* This centers the flex child correctly even when it overflows */
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12); /* More professional shadow for the 'page' */
    background-color: var(--canvas-bg);
    border-radius: 0;
    transition: none; /* No transition for zoom to keep it snappy */
}

/* Contextual Right Panel Groups */
.property-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.property-group:last-child { margin-bottom: 0; }
.flex-row { flex-direction: row; gap: 8px; }

label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.alignment-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.action-grid .icon-btn-text, .alignment-grid .icon-btn-text { 
    justify-content: center; 
    padding: 8px 4px;
    border: 1px solid var(--border-color);
    background: var(--btn-bg);
}
.action-grid .icon-btn-text:hover, .alignment-grid .icon-btn-text:hover {
    border-color: var(--accent-color);
    background: rgba(125, 42, 232, 0.05);
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-panel);
    padding: 6px 12px;
    border-radius: 6px;
    gap: 12px;
    border: 1px solid var(--border-color);
}
input[type="color"] {
    -webkit-appearance: none; appearance: none; border: none;
    width: 24px; height: 24px; border-radius: 50%; cursor: pointer; background: none;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 1px solid var(--border-color); border-radius: 50%; }
.color-val { font-family: monospace; font-size: 0.8rem; color: var(--text-primary); }

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 4px; background: var(--btn-bg-hover); border-radius: 2px; outline: none; margin-top: 4px;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
    background: var(--accent-color); cursor: pointer;
}

/* Small Property Icon Buttons */
.icon-btn-small {
    background: var(--btn-bg); color: var(--text-primary);
    border: 1px solid transparent; border-radius: 4px;
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background 0.2s; flex: 1;
}
.icon-btn-small .material-icons { font-size: 1.1rem; }
.icon-btn-small:hover { background: var(--btn-bg-hover); }
.icon-btn-small.active {
    background: rgba(125, 42, 232, 0.1); color: var(--accent-color); border: 1px solid rgba(125, 42, 232, 0.2);
}

/* Tree View Layers Panel */
.tree-view {
    display: flex; flex-direction: column; flex: 1; min-height: 200px;
}
.layers-header { margin-bottom: 12px; }
.layers-header h3 { font-size: 0.75rem; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }

.layers-list {
    list-style: none; display: flex; flex-direction: column-reverse;
    gap: 6px; overflow-y: auto; flex: 1;
}
.layer-item {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px; background: var(--btn-bg); border-radius: 6px;
    cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
}
.layer-item:hover { background: var(--btn-bg-hover); }
.layer-item.active { background: rgba(125, 42, 232, 0.05); border-color: var(--accent-color); }
.layer-name { flex: 1; font-size: 0.8rem; user-select: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.layer-visibility {
    background: none; border: none; color: var(--text-secondary);
    cursor: pointer; display: flex; align-items: center; width: 16px; height: 16px;
}
.layer-visibility .material-icons { font-size: 1rem; }
.layer-visibility:hover { color: var(--accent-color); }

.layer-item.dragging {
    opacity: 0.5;
    background: var(--btn-bg-hover);
    border: 1px dashed var(--accent-color);
}
.layer-item.drag-over {
    border-top: 2px solid var(--accent-color);
}

/* Hand Tool cursors */
[data-tool="hand"] .material-icons { cursor: grab; }
.tool-btn[data-tool="hand"].active { cursor: grabbing; }

/* Scrollbar overriding */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
/* Custom Font Picker Styles */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

#font-picker-btn {
    height: 48px;
    font-size: 1.1rem;
    padding: 0 16px;
    font-weight: 500;
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    max-height: 400px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 1000;
    overflow-y: auto;
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 4px;
}

.font-item {
    padding: 12px 16px;
    font-size: 1.1rem;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 52px;
    line-height: 1.4;
    display: flex;
    align-items: center;
}

.font-item:hover {
    background: var(--btn-bg-hover);
}

.font-item.selected {
    background: rgba(125, 42, 232, 0.1);
    color: var(--accent-color);
    font-weight: 500;
}

/* Custom Scrollbar for Font Menu */
.custom-select-menu::-webkit-scrollbar {
    width: 5px;
}
.custom-select-menu::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
