/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fafafa;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    padding: 15px 0;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
}

.logo i {
    margin-right: 10px;
    font-size: 1.8rem;
}

.search-container {
    flex: 1;
    max-width: 500px;
    margin: 0 40px;
}

.search-box {
    display: flex;
    background: rgba(255,255,255,0.1);
    border-radius: 25px;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.search-box input {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: white;
    font-size: 16px;
    outline: none;
}

.search-box input::placeholder {
    color: rgba(255,255,255,0.7);
}

.search-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.search-btn:hover {
    background: rgba(255,255,255,0.3);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-primary:hover {
    background: rgba(255,255,255,0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.btn-secondary:hover {
    background: #e9ecef;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.user-menu {
    position: relative;
}

.user-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-btn:hover {
    background: rgba(255,255,255,0.3);
}

.user-btn.active {
    background: rgba(255,255,255,0.35);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.2);
}

/* User Dropdown Styles */
.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    border: 1px solid rgba(0,0,0,0.1);
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    border-radius: 12px 12px 0 0;
    color: white;
}

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

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
    color: white;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-email {
    font-size: 13px;
    opacity: 0.9;
    color: rgba(255,255,255,0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-body {
    padding: 8px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #495057;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.dropdown-item:hover {
    background: #f8f9fa;
    color: #ff6b35;
}

.dropdown-item i {
    width: 16px;
    font-size: 14px;
    color: #6c757d;
    transition: color 0.2s ease;
}

.dropdown-item:hover i {
    color: #ff6b35;
}

.dropdown-item span {
    font-size: 14px;
    font-weight: 500;
}

.dropdown-divider {
    height: 1px;
    background: #e9ecef;
    margin: 8px 0;
}

/* Dropdown arrow */
.user-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 15px;
    width: 12px;
    height: 12px;
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    border-bottom: none;
    border-right: none;
    transform: rotate(45deg);
    border-radius: 2px 0 0 0;
}

/* Main Content */
.main {
    padding: 30px 0;
}

.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
}

.results-info {
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-controls select {
    padding: 8px 15px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
    font-size: 14px;
}

.content-wrapper {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 250px 30px 1fr;
    grid-template-columns: 250px 1fr;
    gap: 30px;
    grid-gap: 30px; /* Fallback for older browsers */
}

/* Sidebar Styles */
.sidebar {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    height: -webkit-fit-content;
    height: -moz-fit-content;
    height: fit-content;
    position: -webkit-sticky;
    position: sticky;
    top: 120px;
    -ms-grid-row: 1;
    -ms-grid-column: 1;
}

.filter-section h3 {
    margin-bottom: 20px;
    color: #495057;
    border-bottom: 2px solid #ff6b35;
    padding-bottom: 10px;
}

.filter-group {
    margin-bottom: 25px;
}

.filter-group h4 {
    margin-bottom: 15px;
    color: #6c757d;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #495057;
    transition: color 0.3s ease;
}

.checkbox-group label:hover {
    color: #ff6b35;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 10px;
    accent-color: #ff6b35;
}

/* Main Content Area */
.main-content {
    background: white;
    border-radius: 12px;
    min-height: 500px;
    -ms-grid-row: 1;
    -ms-grid-column: 3;
    position: relative;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: #6c757d;
}

/* Ensure basic layout works even with JS issues */
.widget-list:empty::after {
    content: "No widgets found or loading...";
    display: block;
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-style: italic;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ff6b35;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.widget-list {
    padding: 0;
}

.widget-item {
    display: flex;
    align-items: flex-start;
    padding: 25px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.3s ease;
}

.widget-item:hover {
    background: #f8f9fa;
}

.widget-item:last-child {
    border-bottom: none;
}

.widget-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 20px;
    flex-shrink: 0;
}

.widget-icon i {
    font-size: 24px;
    color: white;
}

.widget-content {
    flex: 1;
}

.widget-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.widget-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #495057;
    margin-right: 15px;
}

.widget-tags {
    display: flex;
    gap: 8px;
}

.tag {
    background: #e9ecef;
    color: #6c757d;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.tag.primary {
    background: rgba(255, 107, 53, 0.1);
    color: #ff6b35;
}

.widget-description {
    color: #6c757d;
    margin-bottom: 10px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.3s ease;
}

.widget-item:hover .widget-description {
    color: #495057;
}

.widget-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 13px;
    color: #adb5bd;
}

.widget-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.widget-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    margin-left: 20px;
}

.download-count {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    color: #495057;
}

.updated-time {
    font-size: 13px;
    color: #adb5bd;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px;
    background: white;
    border-top: 1px solid #e9ecef;
}

.page-info {
    font-weight: 500;
    color: #495057;
}

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

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 1000px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 300px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

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

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6c757d;
    padding: 5px;
    transition: color 0.3s ease;
}

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

.modal-body {
    padding: 30px;
    overflow-y: auto;
}

.modal-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 25px;
    border-bottom: 1px solid #e9ecef;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn.active {
    color: #ff6b35;
    border-bottom-color: #ff6b35;
}

.tab-btn:hover {
    color: #ff6b35;
}

.tab-content {
    min-height: 400px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.widget-meta {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.widget-meta .meta-item {
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
}

.widget-meta .meta-item:last-child {
    margin-bottom: 0;
}

.widget-description {
    line-height: 1.7;
    color: #495057;
}

.modal-sidebar {
    background: #f8f9fa;
    padding: 30px 25px;
    border-left: 1px solid #e9ecef;
}

.install-section {
    margin-bottom: 30px;
}

.install-section h3 {
    margin-bottom: 15px;
    color: #495057;
}

.install-command {
    display: flex;
    background: #2d3748;
    border-radius: 8px;
    overflow: hidden;
}

.install-command code {
    flex: 1;
    padding: 12px 15px;
    color: #e2e8f0;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
}

.copy-btn {
    background: #4a5568;
    border: none;
    color: #e2e8f0;
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.copy-btn:hover {
    background: #2d3748;
}

.widget-stats {
    margin-bottom: 30px;
}

.widget-stats h4 {
    margin-bottom: 15px;
    color: #495057;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 14px;
    color: #6c757d;
}

.stat-item i {
    color: #ff6b35;
    width: 16px;
}

.widget-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Code Highlighting */
pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.5;
}

code {
    font-family: 'Monaco', 'Menlo', monospace;
    color: #495057;
}

/* Lua Code Section */
.lua-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.lua-code-header h4 {
    margin: 0;
    color: #495057;
    font-size: 16px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

#luaCode {
    background: #2d3748;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

/* Lua syntax highlighting */
.language-lua .comment {
    color: #68d391;
    font-style: italic;
}

.language-lua .keyword {
    color: #f687b3;
    font-weight: bold;
}

.language-lua .string {
    color: #fbb6ce;
}

.language-lua .number {
    color: #90cdf4;
}

.language-lua .function {
    color: #faf089;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .search-container {
        margin: 0;
        max-width: none;
        width: 100%;
    }
    
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: static;
        margin-bottom: 20px;
    }
    
    .modal-content {
        grid-template-columns: 1fr;
        margin: 10px;
    }
    
    .modal-sidebar {
        border-left: none;
        border-top: 1px solid #e9ecef;
    }
    
    .widget-item {
        flex-direction: column;
        text-align: center;
    }
    
    .widget-icon {
        margin: 0 auto 15px auto;
    }
    
    .widget-stats {
        margin-left: 0;
        margin-top: 15px;
        align-items: center;
    }

    /* Mobile responsive for user dropdown */
    .user-dropdown {
        width: 250px;
        right: -10px;
    }

    .dropdown-header {
        padding: 15px;
    }

    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .user-name {
        font-size: 14px;
    }

    .user-email {
        font-size: 12px;
    }
}

/* Animation for widget items */
.widget-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.5s ease forwards;
}

.widget-item:nth-child(1) { animation-delay: 0.1s; }
.widget-item:nth-child(2) { animation-delay: 0.2s; }
.widget-item:nth-child(3) { animation-delay: 0.3s; }
.widget-item:nth-child(4) { animation-delay: 0.4s; }
.widget-item:nth-child(5) { animation-delay: 0.5s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
} 