/* Sidebar Styles */
.sidebar {
    grid-area: sidebar;
    background: linear-gradient(180deg, var(--secondary-bg) 0%, rgba(26, 29, 41, 0.95) 100%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section {
    padding: 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.section-title:after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-color), transparent);
    border-radius: 1px;
}

/* Enhanced Template Categories */
.template-categories {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.template-category {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.template-category:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.template-category:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.template-category:hover:before {
    opacity: 1;
}

.category-header {
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.02);
    -webkit-user-select: none;
    user-select: none;
}

.category-header:hover {
    background: rgba(102, 126, 234, 0.08);
}

.category-icon {
    font-size: 18px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(0, 212, 170, 0.2));
    border-radius: 6px;
    filter: grayscale(20%);
    transition: all 0.3s ease;
}

.category-header:hover .category-icon {
    filter: grayscale(0%);
    transform: scale(1.1);
}

.category-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.3px;
}

.category-arrow {
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 400;
}

.template-category.expanded .category-arrow {
    transform: rotate(180deg);
    color: var(--accent-color);
}

.category-description {
    padding: 8px 16px 16px 52px;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    opacity: 0.8;
    font-style: italic;
}

.category-templates {
    display: none;
    padding: 0 16px 16px;
    animation: slideDown 0.3s ease-out;
}

.template-category.expanded .category-templates {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding-bottom: 0;
    }
    to {
        opacity: 1;
        max-height: 200px;
        padding-bottom: 16px;
    }
}

/* Template Items */
.template-item {
    padding: 12px 14px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.template-item:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.5s ease;
}

.template-item:hover:before {
    left: 100%;
}

.template-item:hover {
    background: rgba(102, 126, 234, 0.08);
    border-color: rgba(102, 126, 234, 0.3);
    transform: translateX(6px);
}

.template-item:active {
    transform: translateX(6px) scale(0.98);
}

.template-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.template-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
    opacity: 0.9;
}

/* AI Template Generator */
.ai-template-generator {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(0, 212, 170, 0.08));
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.ai-template-generator:before {
    content: '✨';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 24px;
    opacity: 0.3;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.3; }
    50% { transform: rotate(10deg) scale(1.1); opacity: 0.6; }
}

.generator-input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.current-template-display {
    background: rgba(0, 212, 170, 0.08);
    border: 1px solid rgba(0, 212, 170, 0.2);
    border-radius: 8px;
    padding: 10px;
    font-size: 11px;
    transition: all 0.3s ease;
}

.current-template-display.has-template {
    background: rgba(0, 212, 170, 0.12);
    border-color: rgba(0, 212, 170, 0.3);
}

.no-template {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    opacity: 0.7;
}

.no-template i {
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-3px); }
    60% { transform: translateY(-2px); }
}

.template-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.template-info .template-name {
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 0; /* Override general template-name margin */
}

.template-info .template-category {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.generator-controls {
    display: flex;
    gap: 8px;
}

.generator-controls .btn {
    flex: 1;
    font-size: 11px;
    padding: 8px 12px;
}

.generator-help {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.8;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border-left: 2px solid var(--accent-color);
}

.generator-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.4;
    resize: vertical;
    min-height: 60px;
    transition: all 0.3s ease;
}

.generator-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.generator-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.generate-template-btn {
    background: linear-gradient(135deg, var(--accent-color), #5a67d8);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.generate-template-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a67d8, var(--accent-color));
}

.generate-template-btn:active {
    transform: translateY(0);
}

/* Template Variables */
.variables-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.variable-tag {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.15), rgba(102, 126, 234, 0.15));
    color: var(--text-primary);
    border: 1px solid rgba(0, 212, 170, 0.3);
    border-radius: 16px;
    padding: 6px 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.variable-tag:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.variable-tag:hover:before {
    left: 100%;
}

.variable-tag:hover {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.25), rgba(102, 126, 234, 0.25));
    border-color: rgba(0, 212, 170, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 170, 0.3);
}

.variable-tag:active {
    transform: translateY(0) scale(0.95);
}

/* Sidebar toggle buttons */
.sidebar-toggle {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    font-weight: 500;
}

.sidebar-toggle:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.sidebar-toggle-header {
    background: linear-gradient(135deg, var(--accent-color), #5a67d8);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    margin-right: 0px;
    font-weight: 600;
}

.sidebar-toggle-header:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.sidebar-toggle-icon {
    transition: transform 0.3s ease;
    font-size: 12px;
}

.studio-container.sidebar-collapsed .sidebar-toggle-icon {
    transform: rotate(180deg);
}

/* Scrollbar styling for sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.4);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.6);
}