* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #202124;
    min-height: 100vh;
    padding: 0;
    overflow: hidden;
}

.main-layout {
    display: flex;
    height: calc(100vh - 100px);
    gap: 0;
    width: 100%;
    margin: 0;
}

.sidebar {
    width: 250px;
    background: #292a2d;
    /* border-radius: 0; */
    /* border-right: 1px solid #5f6368; */
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-header {
    padding: 24px 24px 23px 24px;
    border-bottom: 1px solid #5f6368;
    border-top: 1px solid #5f6368;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    margin: 0;
    color: #e8eaed;
    font-size: 18px;
    font-weight: 600;
}

.btn-icon {
    background: transparent;
    border: none;
    color: #9aa0a6;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    font-size: 18px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.btn-icon:hover {
    background: #3c4043;
    color: #8ab4f8;
}

.project-list-sidebar {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    border-right: 1px solid #5f6368;
}

.project-list-sidebar::-webkit-scrollbar {
    width: 8px;
}

.project-list-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.project-list-sidebar::-webkit-scrollbar-thumb {
    background: #5f6368;
    border-radius: 4px;
}

.project-list-sidebar::-webkit-scrollbar-thumb:hover {
    background: #8ab4f8;
}

.project-item-sidebar {
    padding: 12px 15px;
    background: #3c4043;
    border: 1px solid #5f6368;
    border-radius: 8px;
    color: #e8eaed;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.project-item-sidebar:hover {
    background: #4a4d51;
    border-color: #8ab4f8;
}

.project-item-sidebar.active {
    background: #8ab4f8;
    color: #202124;
    border-color: #8ab4f8;
}

.project-item-sidebar .delete-project {
    margin-left: 5px;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.3s;
}

.project-item-sidebar:hover .delete-project {
    opacity: 0.7;
}

.project-item-sidebar .delete-project:hover {
    opacity: 1;
}

.container {
    width: 100%;
    overflow-y: auto;
    /* padding: 0 10px 10px 10px; */
}

.container::-webkit-scrollbar {
    width: 8px;
}

.container::-webkit-scrollbar-track {
    background: transparent;
}

.container::-webkit-scrollbar-thumb {
    background: #5f6368;
    border-radius: 4px;
}

.container::-webkit-scrollbar-thumb:hover {
    background: #8ab4f8;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #202124;
}

.logo {
    height: 80px;
    width: auto;
}

.user-info {
    color: #9aa0a6;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.user-info button {
    background: none;
    border: none;
    color: #8ab4f8;
    cursor: pointer;
    margin-left: 10px;
    font-size: 14px;
}

.user-info button:hover {
    text-decoration: underline;
}

.header {
    background: #292a2d;
    padding: 20px;
    /* border-radius: 12px; */
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-top: 1px solid #5f6368;
    border-bottom: 1px solid #5f6368;
    flex-shrink: 0;
}


.controls {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto auto auto;
    gap: 15px;
    align-items: center;
}

.search-box input {
    width: 100%;
    padding: 12px 20px;
    border: 1px solid #5f6368;
    border-radius: 25px;
    font-size: 15px;
    transition: all 0.3s;
    background: #202124;
    color: #e8eaed;
}

.search-box input:focus {
    outline: none;
    border-color: #8ab4f8;
    box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.2);
}

.search-box input::placeholder {
    color: #9aa0a6;
}

.filter-group, .sort-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-group label, .sort-group label {
    font-weight: 600;
    color: #e8eaed;
    font-size: 14px;
}

.filter-group select, .sort-group select {
    padding: 10px 15px;
    border: 1px solid #5f6368;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    background: #202124;
    color: #e8eaed;
    transition: border-color 0.3s;
}

.filter-group select:focus, .sort-group select:focus {
    outline: none;
    border-color: #8ab4f8;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary {
    background: #3c4043;
    color: #8ab4f8;
    border: 1px solid #5f6368;
}

.btn-primary:hover {
    background: #4a4d51;
    border-color: #8ab4f8;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(138, 180, 248, 0.3);
}

.btn-danger {
    background: #f28b82;
    color: #202124;
}

.btn-danger:hover {
    background: #f6aea9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(242, 139, 130, 0.4);
}

.btn-secondary {
    background: #3c4043;
    color: #e8eaed;
    border: 1px solid #5f6368;
}

.btn-secondary:hover {
    background: #4a4d51;
    transform: translateY(-2px);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #292a2d;
    padding: 30px;
    border-radius: 16px;
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: slideIn 0.3s ease;
    border: 1px solid #5f6368;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #9aa0a6;
    margin-bottom: 25px;
    font-size: 18px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #9aa0a6;
    font-weight: 500;
    font-size: 13px;
}

.form-group input[type="text"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #5f6368;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.3s;
    background: #292a2d;
    color: #e8eaed;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #8ab4f8;
}

.form-group input[type="text"]::placeholder,
.form-group textarea::placeholder {
    color: #9aa0a6;
}

.form-group textarea {
    min-height: 120px;
    resize: none;
    overflow: hidden;
}

/* New note edit modal styles */
.note-edit-modal {
    background: #202124;
    border: 1px solid #5f6368;
    padding: 0;
    max-width: 800px;
}

.note-edit-main {
    padding: 30px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #202124;
    transition: background 0.3s ease;
}

.note-edit-title {
    font-size: 22px;
    font-weight: bold;
    color: #e8eaed;
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    padding: 0;
    font-family: inherit;
}

.note-edit-title::placeholder {
    color: #5f6368;
    font-weight: normal;
}

.note-edit-description {
    font-size: 15px;
    color: #9aa0a6;
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    padding: 0;
    font-family: inherit;
    line-height: 1.6;
    resize: none;
    overflow: hidden;
    min-height: 150px;
    white-space: pre-wrap;
}

.note-edit-description::placeholder {
    color: #5f6368;
}

/* Removed .note-edit-options - now using compact toolbar in modal-actions */

.option-group label {
    display: block;
    margin-bottom: 6px;
    color: #9aa0a6;
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.option-group input[type="text"],
.option-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #5f6368;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
    background: #202124;
    color: #e8eaed;
}

.option-group input[type="text"]:focus,
.option-group select:focus {
    outline: none;
    border-color: #8ab4f8;
}

.option-group input[type="text"]::placeholder {
    color: #5f6368;
}

/* Color picker in dropdown */
.color-dropdown .color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-dropdown .color-option:hover {
    transform: scale(1.1);
    border-color: #5f6368;
}

.color-dropdown .color-option.selected {
    border-color: #8ab4f8;
    transform: scale(1.05);
}

.note-edit-modal .modal-actions {
    padding: 12px 20px;
    background: #292a2d;
    border-top: 1px solid #5f6368;
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.modal-actions-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.modal-actions-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.compact-option {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.compact-option i {
    color: #9aa0a6;
    font-size: 18px;
}

.compact-select {
    background: #3c4043;
    border: 1px solid #5f6368;
    border-radius: 8px;
    color: #e8eaed;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    max-width: 150px;
}

.compact-select:hover {
    background: #444;
}

.icon-btn {
    background: transparent;
    border: none;
    color: #9aa0a6;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 18px;
}

.icon-btn:hover {
    background: #3c4043;
    color: #e8eaed;
}

.icon-btn.active {
    color: #8ab4f8;
}

.icon-btn i {
    font-size: 18px;
}

/* Dropdown containers */
.compact-option-label,
.compact-option-color {
    position: relative;
}

.label-dropdown,
.color-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: #292a2d;
    border: 1px solid #5f6368;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.label-dropdown {
    width: 250px;
}

.label-dropdown input {
    width: 100%;
    background: #3c4043;
    border: 1px solid #5f6368;
    border-radius: 6px;
    color: #e8eaed;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
}

.label-dropdown input:focus {
    border-color: #8ab4f8;
}

.color-dropdown {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding: 10px;
    width: auto;
}

.color-picker {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.color-option {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s;
    position: relative;
}

.color-option:hover {
    transform: scale(1.15);
}

.color-option.selected {
    border-color: #8ab4f8;
    transform: scale(1.2);
}

.color-option.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #8ab4f8;
    font-size: 20px;
    font-weight: bold;
}

.image-upload {
    position: relative;
}

.image-upload input[type="file"] {
    padding: 10px 0;
}

.image-preview {
    max-width: 150px;
    max-height: 150px;
    border-radius: 10px;
    object-fit: contain;
    background: #000;
}

.image-preview-container {
    position: relative;
    display: inline-block;
    margin-top: 15px;
}

.image-preview-item {
    position: relative;
    display: inline-block;
}

/* Hide remove button by default, show on hover */
.image-preview-item .remove-image-btn {
    opacity: 0;
    transition: opacity 0.3s;
}

.image-preview-item:hover .remove-image-btn {
    opacity: 1;
}

.remove-image-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* Edit modal image styles */
.image-preview-container-edit {
    display: block;
    margin-top: 15px;
}

.note-images-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.note-images-edit .image-preview-item {
    position: relative;
    display: inline-block;
}

.note-images-edit .image-preview {
    width: auto;
    max-height: 150px;
    object-fit: contain;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.3s;
}   

/* Multiple images in grid */
.note-images-edit .image-preview-item {
    width: auto;
    display: inline-block;
}

.note-images-edit .image-preview-item .image-preview {
    max-height: 120px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 25px;
    flex-wrap: wrap;
}

.grid-stack {
    background: transparent;
    min-height: 400px;
}

.grid-stack-item {
    scroll-margin: 0;  /* Prevent scroll-into-view behavior */
}

.grid-stack-item-content {
    background: #202124;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    cursor: move;
    transition: all 0.3s;
    border: 1px solid #5f6368;
    display: flex;
    flex-direction: column;
}

.grid-stack-item-content:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    transform: translateY(-4px);
}

.note {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.note-title {
    font-weight: bold;
    font-size: 17px;
    color: #e8eaed;
    word-wrap: break-word;
    flex: 1;
    line-height: 1.4;
}

.note-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s;
}

.grid-stack-item:hover .note-actions {
    opacity: 1;
}

/* Always show action buttons on touch/mobile devices */
@media (hover: none), (pointer: coarse) {
    .note-actions {
        opacity: 1;
    }
}

.note-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #9aa0a6;
    padding: 6px 8px;
    border-radius: 6px;
    transition: all 0.3s;
    line-height: 1;
}

.note-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #e8eaed;
}

.note-description {
    color: #9aa0a6;
    font-size: 14px;
    word-wrap: break-word;
    overflow: hidden;
    line-height: 1.6;
    white-space: pre-wrap;
    flex: 1;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 20;
}

.image-link {
    color: #8ab4f8;
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.image-link:hover {
    color: #aecbfa;
    border-bottom-color: #aecbfa;
}

.note-label {
    display: inline-block;
    padding: 5px 12px;
    background: rgba(138, 180, 248, 0.2);
    border-radius: 15px;
    font-size: 12px;
    color: #aecbfa;
    font-weight: 500;
}

.note-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.note-labels .note-label {
    margin: 0;
}

.note-image {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    margin: 8px 0;
    cursor: pointer;
    transition: opacity 0.3s;
}

.note-image:hover {
    opacity: 0.8;
}

.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.image-modal.active {
    display: flex;
}

.image-modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.image-modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.note-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 4px;
    margin: 8px 0;
    overflow: hidden;
    flex-shrink: 1;
}

.note-images .note-image {
    margin: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    max-height: none;
    aspect-ratio: 1 / 1;
}

.note-images .note-image:only-child {
    grid-column: 1 / -1;
    max-height: 100%;
    object-fit: contain;
    aspect-ratio: auto;
}

.empty-state {
    text-align: center;
    color: #9aa0a6;
}

.empty-state p {
    font-size: 20px;
    margin-bottom: 10px;
    color: #e8eaed;
}

.empty-state small {
    font-size: 16px;
    opacity: 0.8;
}

.project-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.project-item {
    padding: 12px 15px;
    background: #3c4043;
    border: 1px solid #5f6368;
    border-radius: 8px;
    color: #e8eaed;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-item:hover {
    background: #4a4d51;
    border-color: #8ab4f8;
}

.project-item.selected {
    background: #8ab4f8;
    color: #202124;
    border-color: #8ab4f8;
}

.templates-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.template-item {
    padding: 12px 15px;
    background: #3c4043;
    border: 1px solid #5f6368;
    border-radius: 8px;
    color: #e8eaed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.template-item:hover {
    background: #4a4d51;
    border-color: #8ab4f8;
}

.template-item-info {
    flex: 1;
    min-width: 0;
}

.template-item-title {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-item-labels {
    font-size: 12px;
    color: #9aa0a6;
}

.template-item-labels i {
    margin-right: 4px;
}

.template-item-actions {
    display: flex;
    gap: 8px;
    margin-left: 10px;
}

.template-item-actions button {
    background: none;
    border: none;
    color: #9aa0a6;
    cursor: pointer;
    padding: 5px;
    font-size: 16px;
    transition: color 0.3s;
}

.template-item-actions button:hover {
    color: #8ab4f8;
}

.template-item-actions button.delete:hover {
    color: #f28b82;
}

/* Lazy loading placeholder */
img.lazy {
    opacity: 0.5;
    transition: opacity 0.3s;
}

img.lazy[src*="data:image/svg"] {
    filter: blur(2px);
}

img:not(.lazy) {
    opacity: 1;
}

@media (max-width: 1024px) {
    .controls {
        grid-template-columns: 1fr 1fr;
    }

    .search-box {
        grid-column: 1 / -1;
    }

    .main-layout {
        flex-direction: column;
        height: auto;
    }

    .sidebar {
        width: 100%;
        max-height: 200px;
    }
}

@media (max-width: 768px) {
    .controls {
        grid-template-columns: 1fr;
    }

    .filter-group, .sort-group {
        justify-content: space-between;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .note-edit-modal {
        width: 100%;
        margin: 10px;
    }

    .note-edit-main {
        padding: 20px;
    }

    .modal-actions-left,
    .modal-actions-right {
        flex-wrap: wrap;
    }

    .compact-select {
        max-width: 120px;
        font-size: 12px;
    }

    .note-edit-modal .modal-actions {
        flex-wrap: wrap;
        gap: 10px;
    }

    .sidebar {
        max-height: 150px;
    }

    body {
        /* overflow: auto; */
    }
}

/* Loading spinner animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}
