* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* 🔥 Sticky Top Bar Styles (Oval Style) */
.top-bar {
    position: sticky;
    top: 0;
    max-width: 1400px;   /* ✅ match your main-container */
    margin: 10px auto;   /* ✅ center it */
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 30px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 1000;
}

/* Logo */
.top-bar .logo img {
    height: 40px;
    border-radius: 10px;
}

/* Menu */
.top-bar .menu {
    display: flex;
    gap: 25px;
}

.top-bar .menu a {
    text-decoration: none;
    color: #333;
    font-weight: 600;
    transition: color 0.2s;
}

.top-bar .menu a:hover {
    color: #667eea;
}

/* User Section */
.user-section {
    display: flex;
    gap: 10px;
    font-weight: 600;
}

/* Dropdown */
.user-dropdown {
    position: relative;
    cursor: pointer;
}

.user-dropdown .dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 110%;
    background: white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-radius: 12px;
    overflow: hidden;
    min-width: 160px;
}

.user-dropdown .dropdown-content a {
    display: block;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
}

.user-dropdown .dropdown-content a:hover {
    background: #f0f0f0;
}

.user-dropdown.show .dropdown-content {
    display: block;
}

/* Welcome text styles */
.welcome-text {
    color: #667eea;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* User dropdown styles */
.user-dropdown, .login-dropdown {
    position: relative;
    cursor: pointer;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: background-color 0.3s;
    color: white;
}

.user-dropdown:hover, .login-dropdown:hover {
    background: rgba(255, 255, 255, 0.2);
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    min-width: 280px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    margin-top: 0.5rem;
    padding: 1rem;
}

.user-dropdown.show .dropdown-content,
.login-dropdown.show .dropdown-content {
    display: block;
}

.dropdown-content a {
    display: block;
    padding: 0.75rem 1rem;
    color: white;
    text-decoration: none;
    transition: background-color 0.3s;
    border-radius: 8px;
    margin-bottom: 0.25rem;
}

.dropdown-content a:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Login form styles */
.login-form {
    color: white;
}

.form-tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: white;
    border-bottom-color: #667eea;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-form input {
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
}

.auth-form input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.auth-form input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.auth-btn {
    padding: 0.75rem;
    background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.2s;
    margin-top: 0.5rem;
}

.auth-btn:hover {
    transform: translateY(-1px);
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-message {
    margin-top: 0.75rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
}

.auth-message.error {
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.5);
    color: #ff6b6b;
}

.auth-message.success {
    background: rgba(81, 207, 102, 0.2);
    border: 1px solid rgba(81, 207, 102, 0.5);
    color: #51cf66;
}

/* Hide login dropdown content from screen readers when closed */
.login-dropdown:not(.show) .dropdown-content {
    visibility: hidden;
}

.login-dropdown.show .dropdown-content {
    visibility: visible;
}

.main-container {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 40px);
    .main-container {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 32px;
    }
}

.panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow-y: auto;
}

.left-panel {
    flex: 0 0 280px;
}

.center-panel {
    flex: 1;
    min-width: 400px;
    .panel.center-panel-expanded {
        flex: 1 1 0;
        min-width: 0;
    }
}

/* New expanded center panel styles */
.center-panel-expanded {
    flex: 1;
    min-width: 600px;
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow-y: auto;
}

/* Collapsible Settings Section */
.settings-section {
    margin-bottom: 25px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
}

.settings-toggle {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.settings-toggle:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6b4190 100%);
}

.settings-toggle .settings-icon {
    font-size: 18px;
}

.settings-toggle .settings-text {
    flex: 1;
    text-align: left;
    margin-left: 10px;
}

.settings-toggle .toggle-arrow {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.settings-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #f8f9fa;
}
    /* Moved from index.html inline styles */
    #generateForm > div[style*="margin-bottom"] {
        margin-bottom: 24px;
    }

    .settings-content .form-row {
        display: flex;
        gap: 16px;
        align-items: center;
        margin-bottom: 8px;
    }

    .settings-content .form-group[style*="flex-direction: column"] {
        display: flex;
        flex-direction: column;
    }

    .settings-content input[type="number"] {
        width: 90px;
    }

.settings-content.expanded {
    max-height: 400px;
    padding: 20px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.right-panel {
    flex: 0 0 320px;
    .panel.right-panel {
        width: 320px;
        flex-shrink: 0;
        background: #f8f9fa;
        border-left: 1px solid #e0e0e0;
        min-height: 600px;
    }
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8em;
}

h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.2em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
}

h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.2em;
    padding-bottom: 5px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    transition: border-color 0.3s;
}

input[type="number"], input[type="range"] {
    width: 100%;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

textarea:focus, input:focus {
    outline: none;
    border-color: #667eea;
}

.range-group {
    margin-bottom: 15px;
}

.range-value {
    font-weight: bold;
    color: #667eea;
    margin-left: 10px;
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    display: block;
    margin: 20px auto;
    width: 80%;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.loading {
    display: none;
    text-align: center;
    margin: 20px 0;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.result {
    display: none;
    text-align: center;
    margin-top: 30px;
}

.result img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.download-btn {
    background: #28a745;
    margin-top: 15px;
    display: inline-block;
    text-decoration: none;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
}

.error {
    color: #dc3545;
    padding: 10px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    margin: 10px 0;
    display: none;
}

/* History Panel Styles */
.history-container {
    display: flex;
    flex-direction: column;
    height: calc(100% - 60px);
}

.history-images {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;   /* vertical stacking */
    gap: 10px;
    padding: 10px 0;
}
.history-item img {
    width: 100%;   /* adjust width */
    height: auto;  /* keep aspect ratio */
    object-fit: contain;
}

.history-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.history-item:hover {
    transform: scale(1.02);
}

.history-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.history-item .timestamp {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 5px;
    font-size: 10px;
    text-align: center;
}

.clear-history {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 10px;
}

.clear-history:hover {
    background: #c82333;
}

/* 🖼️ Gallery Styles */
.gallery-container {
    max-width: 1400px;
    margin: 20px auto;
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
    text-align: center;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.gallery-item {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    background: #f8f8f8;
    position: relative;
}

.gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.gallery-item .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    padding: 10px;
    transform: translateY(100%);
    transition: transform 0.2s;
}

.gallery-item:hover .overlay {
    transform: translateY(0);
}

.download-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 5px;
    transition: background 0.2s;
}

.download-btn:hover {
    background: #5a6fd8;
}

.no-images {
    text-align: center;
    color: #666;
    font-style: italic;
    grid-column: 1 / -1;
    padding: 40px;
}

.loading {
    text-align: center;
    color: #666;
    grid-column: 1 / -1;
    padding: 40px;
}
/* Pagination Styles - Deep Purple Theme */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0;
    padding: 1rem;
    background: #2a003f; /* very deep purple background */
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(64, 0, 128, 0.6);
}

.pagination-btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #4c0099 0%, #30004d 100%);
    border: 2px solid #5e00c2;
    border-radius: 12px;
    color: #e0b3ff; /* light lavender text */
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(90, 0, 180, 0.5);
}

.pagination-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #6a00cc 0%, #42006e 100%);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(150, 0, 255, 0.6);
    color: #f0d5ff; /* slightly brighter text on hover */
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #1a0029;
    border-color: #2d0047;
    color: #7a4f99;
    box-shadow: none;
}

.pagination-info {
    color: #c69cff; /* lavender text for visibility */
    font-size: 1rem;
    margin: 0 1rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    background: #3a005c;
    border-radius: 10px;
    box-shadow: inset 0 0 8px rgba(128, 0, 255, 0.5);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
        height: auto;
    }

    .left-panel, .right-panel, .center-panel-expanded {
        flex: none;
    }

    .history-images {
        grid-template-columns: repeat(4, 1fr);
        height: 200px;
    }

    .settings-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .main-container {
        padding: 10px;
        gap: 10px;
    }

    .panel, .center-panel-expanded {
        padding: 15px;
    }

    .history-images {
        grid-template-columns: repeat(3, 1fr);
    }

    .settings-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .settings-content.expanded {
        padding: 15px;
    }

    .top-bar {
        flex-direction: column;
        gap: 10px;
        padding: 15px 20px;
        border-radius: 20px;
    }

    .top-bar .menu {
        gap: 15px;
    }
}