/* Base Styles */
* { box-sizing: border-box; }

/* Global transparency for visualizer UI containers */
#categories-panel,
#mode-buttons,
#zoom-controls,
.modal-content {
    opacity: 0.9;
}

/* Global container perimeter styling */
#categories-panel,
#zoom-controls,
.modal-content,
.panel-section,
.category-section,
.folder-section,
.option-item,
.room-item {
    border: 2px solid rgba(222,226,230,0.4);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.panel-section {
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    overflow: hidden;
}

.panel-header {
    background: rgba(248,249,250,0.1);
    transition: all 0.2s;
    font-weight: 600;
    font-size: 0.9rem;
}

.panel-header:hover {
    background: rgba(233,236,239,0.2);
}

.panel-title {
    color: #495057;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.modal-header h3 {
    margin: 0;
    color: #495057;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #dc3545;
}

.modal-body {
    padding: 1rem;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    color: #495057;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}

.form-help {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.btn-primary,
.btn-secondary {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
}

/* Category Styles */
.category-section {
    margin-bottom: 0.5rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: rgba(248,249,250,0.1);
    cursor: pointer;
    transition: all 0.2s;
}

.category-header:hover {
    background: rgba(233,236,239,0.2);
}

.category-content {
    display: none;
    padding: 0.75rem;
    background: rgba(255,255,255,0.05);
}

.category-content.expanded {
    display: block;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.75rem;
}

/* Error Notification Styles */
.error-notification,
.success-notification {
    background: white;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-left: 4px solid;
    pointer-events: auto;
    animation: slideIn 0.3s ease;
}

.error-notification {
    border-left-color: #dc3545;
}

.success-notification {
    border-left-color: #28a745;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.error-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.error-message {
    flex-grow: 1;
    color: #495057;
    font-size: 0.9rem;
    line-height: 1.4;
}

.error-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.error-close:hover {
    color: #dc3545;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Option Styles */
.option-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0.4rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
}

.option-item:hover {
    transform: translateY(-1px);
    border-color: rgba(0,123,255,0.4);
    background: rgba(255,255,255,0.3);
}

.option-item.selected {
    border-color: rgba(40,167,69,0.6);
    background: rgba(248,255,249,0.3);
    transform: scale(1.2);
    z-index: 10;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.option-thumbnail {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    border: 1px solid rgba(221,221,221,0.6);
    margin-bottom: 0.4rem;
    background-size: cover;
    background-position: center;
    transition: all 0.3s ease;
}

.option-item.selected .option-thumbnail {
    width: 100%;
    height: 140px;
    border-width: 2px;
    border-color: rgba(40,167,69,0.8);
    margin-bottom: 0.2rem;
}

.option-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.2rem;
    line-height: 1.2;
}

.option-price {
    font-size: 0.65rem;
    color: #6c757d;
}

/* Room Styles */
.room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid rgba(222,226,230,0.2);
    background: rgba(255,255,255,0.1);
    font-size: 0.8rem;
    transition: all 0.2s;
}

.room-item:hover {
    background: rgba(255,255,255,0.2);
}

.room-item.selected {
    border-color: rgba(40,167,69,0.6);
    background: rgba(248,255,249,0.3);
    color: #28a745;
}

/* Button Styles */
.zoom-btn {
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(222,226,230,0.3);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: rgba(255,255,255,1);
    transform: translateY(-1px);
}

/* Custom Options Styles */
.custom-options-section {
    margin-top: 1rem;
    border-top: 1px solid rgba(222,226,230,0.3);
    padding-top: 1rem;
}

.add-custom-option:hover {
    border-color: #007bff;
    color: #007bff;
    background: rgba(0,123,255,0.05);
}

.custom-option-item {
    transition: all 0.2s;
}

.custom-option-item:hover {
    background: #e9ecef !important;
    transform: translateY(-1px);
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.modal-body {
    padding: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-primary {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
}

/* Global clickable elements cursor */
button, .btn, .option-item, .room-item, .category-header, .folder-header, .panel-header, 
.add-new-option, .add-new-category, .add-new-folder, .zoom-btn, .tab-btn, .thumbnail-option,
[onclick], [data-onclick], .clickable {
    cursor: pointer !important;
}

.add-new-option, .add-new-category, .add-new-folder {
    border: 2px dashed rgba(40,167,69,0.4) !important;
    background: rgba(40,167,69,0.1) !important;
    color: rgba(40,167,69,0.8) !important;
}

.add-new-folder:hover {
    background: rgba(40,167,69,0.2) !important;
    border-color: rgba(40,167,69,0.6) !important;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    min-width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
    color: #495057;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
}

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

/* Admin mode styles */
.sales-mode .admin-only {
    display: none !important;
}

/* Folder Styles */
.folder-section {
    margin-bottom: 0.5rem;
    border: 1px solid rgba(222,226,230,0.3);
    border-radius: 6px;
    background: rgba(248,249,250,0.3);
}

.folder-header {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    gap: 0.5rem;
}

.folder-header:hover {
    background: rgba(233,236,239,0.4);
}

.folder-icon {
    font-size: 0.9rem;
}

.folder-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: #495057;
    flex: 1;
}

.folder-content {
    padding: 0.5rem;
    border-top: 1px solid rgba(222,226,230,0.2);
}

.folder-content.expanded {
    display: grid !important;
}

.admin-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Drag and Drop Styles */
.option-item[draggable="true"] {
    cursor: move;
}

.option-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.folder-content.drag-over {
    background: rgba(40,167,69,0.1);
    border: 2px dashed rgba(40,167,69,0.4);
}

.options-grid.drag-over {
    background: rgba(40,167,69,0.1);
    border: 2px dashed rgba(40,167,69,0.4);
    border-radius: 6px;
}

.folder-header.drag-over {
    background: rgba(40,167,69,0.2) !important;
    border: 2px dashed rgba(40,167,69,0.6);
    border-radius: 6px;
}

.category-header.drag-over {
    background: rgba(40,167,69,0.2) !important;
    border: 2px dashed rgba(40,167,69,0.6);
    border-radius: 6px;
}

.category-section[draggable="true"] {
    cursor: move;
}

.category-section.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

/* Mobile responsive */
@media (max-width: 768px) {
    #categories-panel {
        width: min(200px, 40vw) !important;
        min-width: 160px !important;
    }

    .option-thumbnail {
        width: 40px !important;
        height: 40px !important;
    }

    .options-grid {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)) !important;
    }

    .folder-header {
        padding: 0.4rem !important;
    }

    .folder-name {
        font-size: 0.7rem !important;
    }
}

/* Error Notifications */
.error-notification,
.success-notification {
    background: white;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border-left: 4px solid;
    pointer-events: auto;
    animation: slideInRight 0.3s ease-out;
    max-width: 100%;
    overflow: hidden;
}

.error-notification {
    border-left-color: #dc3545;
}

.success-notification {
    border-left-color: #28a745;
}

.error-notification.error-network {
    border-left-color: #6610f2;
}

.error-notification.error-validation {
    border-left-color: #fd7e14;
}

.error-notification.error-permission {
    border-left-color: #e83e8c;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.error-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.error-message {
    flex-grow: 1;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #495057;
}

.error-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.error-close:hover {
    background: rgba(0,0,0,0.1);
    color: #495057;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Spinner */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    display: inline-block;
}

/* Enhanced Modal Styles */
.modal-content.small {
    max-width: 400px;
}

.modal-content.medium {
    max-width: 600px;
}

.modal-content.large {
    max-width: 800px;
}

/* Form elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: #495057;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #6c757d;
}

.modal-form .form-group:last-child {
    margin-bottom: 0;
}

#categories-container {
    flex: 1;
    padding: 0.5rem;
    overflow-y: auto;
    position: relative;
    transition: margin-top 0.3s ease;
}

#room-content {
    transition: max-height 0.3s ease;
    overflow: hidden;
}

#room-selector-section {
    flex-shrink: 0;
}