button {
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
}

/* New Project Button */
.new-project-btn {
    width: 100%;
    padding: 12px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    border-radius: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
}

.new-project-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Magic Generate Button */
.btn-magic {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent-color) 0%, #a855f7 100%);
    border: none;
    color: white;
    border-radius: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
    transition: all 0.3s ease;
}

.btn-magic:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5);
    filter: brightness(1.1);
}

.btn-magic i {
    width: 18px;
    height: 18px;
}

/* Action Cards */
.main-actions {
    display: flex;
    gap: 50px;
    margin-top: 40px;
    flex-wrap: wrap;
    justify-content: center;
}


.action-card {
    width: 220px;
    height: 220px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    text-align: center;
    color: var(--text-primary);
}


/* Lucide replaces <i> with <svg>, so we target svg */
.action-card svg {
    width: 120px;
    height: 120px;
    color: var(--text-primary);
    stroke-width: 1.5;
}

.action-card span {
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.2;
}

@media (max-width: 768px) {
    .action-card {
        width: 140px;
        height: 140px;
        padding: 12px;
        gap: 8px;
    }

    .action-card svg {
        width: 70px;
        height: 70px;
    }

    .action-card span {
        font-size: 0.8rem;
    }

    .main-actions {
        gap: 16px;
    }
}

.product-list-scroll {
    overflow-y: auto;
    flex-grow: 1;
    /* Custom scrollbar if needed, usually global one applies */
}

.product-search-input {
    width: 100%;
    padding: 6px 10px;
    background: var(--input-bg, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    margin-bottom: 12px;
    outline: none;
    transition: all 0.2s;
}

.product-search-input:focus {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
}

.product-search-input::placeholder {
    color: var(--text-secondary);
}

.action-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-color);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.15);
}

/* Project List Items */
.project-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

/* Custom Scrollbar for Project List - Removed in favor of global style */

.project-item {
    padding: 12px;
    border-radius: 12px;
    background: transparent;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    /* Context for absolute positioning if needed, though we use flex */
}

.project-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--panel-border);
}

.project-item:hover .project-delete-btn {
    opacity: 1;
    pointer-events: auto;
}

.project-delete-btn {
    opacity: 0;
    pointer-events: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    /* Gray default */
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: auto;
    /* Push to right */
}

.project-delete-btn:hover {
    color: #ef4444;
    /* Red on hover */
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

.project-delete-btn svg {
    width: 16px;
    height: 16px;
}

.project-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.project-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-thumb {
    width: 48px;
    height: 48px;
    background: #333;
    border-radius: 8px;
    object-fit: cover;
    background-size: cover;
    background-position: center;
}

/* Rename Container */
.rename-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.rename-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--accent-color);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 2px 6px;
    flex: 1;
    min-width: 0;
    /* Important to allow shrinking in flex */
    outline: none;
    font-size: inherit;
    font-family: inherit;
}

.sidebar-right {
    width: var(--sidebar-right-width);
    flex-shrink: 0;
    padding: 20px;
}

/* RTL Support */
[dir="rtl"] .app-container {
    flex-direction: row-reverse;
}

.delete-btn {
    background: transparent;
    color: #ef4444;
    /* Red color for delete */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

.delete-btn i {
    width: 16px;
    height: 16px;
}

/* Language Switcher */
.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--panel-border);
}

/* Search UI */
.search-container {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 8px 12px;
    gap: 8px;
    transition: all 0.2s;
}

.search-container:focus-within {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.search-icon {
    width: 16px !important;
    height: 16px !important;
    color: var(--text-secondary);
}

.search-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 100%;
    font-family: inherit;
}

.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Modal System */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10000;
    /* Increased z-index */
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex !important;
    /* Force display */
}

.modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius);
    padding: 24px;
    max-width: 90vw;
    width: 640px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 10001;
}

.camera-wrap {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#camera-video {
    width: 100%;
    border-radius: 8px;
    background: #000;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

/* Project View */
.project-view-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

#home-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    /* For absolute positioning of logout */
}

.logout-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    /* LTR default */
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    z-index: 10;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border-color: rgba(239, 68, 68, 0.2);
}

[dir="rtl"] .logout-btn {
    right: auto;
    left: 20px;
}

/* Ensure project-view takes full space */
#project-view {
    width: 100%;
    height: 100%;
}

.project-view-header {
    width: 100%;
    /* Remove max-width to allow full span for corner button */
    display: flex;
    justify-content: center;
    /* Center the input */
    align-items: center;
    margin-bottom: 20px;
    position: relative;
    /* Context for absolute positioning */
    min-height: 48px;
}

.project-title-input {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    /* Less wide and centered */
    width: 100%;
    max-width: 400px;
    text-align: center;
    transition: all 0.2s;
}

.project-title-input:hover,
.project-title-input:focus {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--panel-border);
    outline: none;
}

.btn-delete-project {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;

    /* Position strictly in the corner */
    position: absolute;
    inset-inline-end: 0;
    /* Right for LTR, Left for RTL */
    top: 50%;
    transform: translateY(-50%);
}

.btn-delete-project:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-50%) scale(1.05);
}

/* project-image-center wrapper if we decide to add one, otherwise standard wrapper */
.project-image-wrapper {
    max-width: 100%;
    max-height: 80vh;
    /* Prevent taking up too much vertical space */
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    display: flex;
    justify-content: center;
    background: #000;
}

.project-main-image {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}



/* Download Button */
.btn-download-image {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 0;
    /* Handled by gap */
    padding: 6px 12px;
    /* Smaller padding */
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    /* Smaller radius */
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    /* Smaller font */
    transition: all 0.2s;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    flex-shrink: 0;
    /* Don't shrink button */
}

/* Product List Pane (Bottom of Sidebar) */
/* Product List Pane (Bottom of Sidebar) */
.product-list-container {
    flex: 1 1 200px;
    /* Grow, Shrink, Basis */
    height: auto;
    min-height: 200px;
    overflow-y: auto;
    border-top: 1px solid var(--panel-border);
    padding-top: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-top: 10px;
}

.product-list-container h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.product-flat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.product-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 2px solid transparent;
}

.product-list-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.product-list-item.active {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-color);
}

.product-list-item .product-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
    background: #000;
}

.product-list-item span {
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    /* Prevent wrapping */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Generation Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.generation-modal-content {
    background: var(--panel-bg);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    text-align: center;
    min-width: 300px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.status-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.5rem;
}

#gen-status-text {
    margin-top: 1rem;
    font-size: 1.1rem;
    color: var(--text-primary);
}

/* Magic Loader */
.magic-loader {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.magic-orb {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, #fff, var(--accent-color));
    border-radius: 50%;
    box-shadow: 0 0 30px var(--accent-color), 0 0 60px var(--accent-color);
    animation: pulse 2s infinite ease-in-out;
    z-index: 2;
    filter: blur(1px);
}

.magic-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(168, 85, 247, 0.1);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 3s linear infinite;
}

.magic-ring:nth-child(3) {
    width: 75%;
    height: 75%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid #fff;
    animation: spin-reverse 2s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes spin-reverse {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(-360deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
        box-shadow: 0 0 20px var(--accent-color);
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
        box-shadow: 0 0 40px var(--accent-color), 0 0 10px #fff;
    }

    100% {
        transform: scale(0.95);
        opacity: 0.8;
        box-shadow: 0 0 20px var(--accent-color);
    }
}

/* Step History */
.step-history-container {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    /* Prevent vertical scroll */
    gap: 12px;
    padding: 12px;
    width: 100%;
    min-height: 140px;
    /* Force minimum height for 100px items + padding */
    align-items: center;
    /* border-top: 1px solid var(--panel-border); */
    background: transparent;
    border-radius: 12px;
    margin-top: 10px;
}

.step-history-item {
    position: relative;
    flex: 0 0 100px;
    /* Fixed width, no shrink */
    height: 100px;
    /* Fixed height */
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.step-history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.step-history-item:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.step-history-item.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

/* Download Button */
.btn-download-image {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    /* Explicit gap between image and button */
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.2s;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.btn-download-image:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}