/* Modern CSS Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Variables */
:root {
    --bg-primary: #0f1116;
    --bg-secondary: #1a1d23;
    --bg-tertiary: #22252d;
    --accent-blue: #2563eb;
    --accent-orange: #f97316;
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --border-color: #2d3139;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --gradient: linear-gradient(135deg, var(--accent-blue), var(--accent-orange));
}

/* Typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

.brand-text {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    color: var(--text-primary);
}

/* Common Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--gradient);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

/* Form Elements */
.form-control {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    padding: 1rem !important;
    border-radius: 12px !important;
    transition: all 0.2s ease;
}

.form-control:focus {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--accent-blue) !important;
    box-shadow: none !important;
}

.form-label {
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-select {
    background-color: var(--bg-tertiary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    padding: 0.75rem 1rem !important;
    border-radius: 12px !important;
}

/* Navbar */
.navbar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.brand-icon {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.navbar-brand .brand-text {
    font-size: 1.5rem;
}

.navbar-brand i {
    font-size: 1.75rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-link {
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
}

.card-body {
    color: #ffffff;
}

/* Auth Pages (Login/Register) */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    animation: fadeIn 0.6s ease-out;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo i {
    font-size: 2.5rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
    text-align: center;
}

/* Main Content Area */
.main-content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.mode-card {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.mode-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient);
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: 16px 16px 0 0;
}

.mode-card.active::before {
    opacity: 1;
}

.mode-card:hover {
    transform: translateY(-4px);
}

.mode-card i {
    font-size: 2rem;
    margin-bottom: 1rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Alerts */
.alert {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.alert-success {
    border-left: 4px solid #10b981;
}

.alert-danger {
    border-left: 4px solid #ef4444;
}

/* History Grid */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.history-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
}

.history-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 20px var(--shadow-color);
}

.history-item img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    cursor: pointer;
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    padding: 2rem;
    cursor: pointer;
}

.image-modal img {
    max-width: 90%;
    max-height: 90vh;
    margin: auto;
    display: block;
    object-fit: contain;
}

.image-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

/* Modal */
.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .mode-selector {
        flex-direction: column;
    }
    
    .navbar {
        padding: 1rem;
    }

    .main-content {
        padding: 1rem;
    }

    .auth-card {
        padding: 1.5rem;
    }
}

/* Footer */
.footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer a {
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: var(--text-primary) !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background-color: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background-color: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--border-color);
}

/* Register Page Specific Styles */
.divider {
    position: relative;
}

.divider:after,
.divider:before {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.text-primary {
    color: var(--accent-blue) !important;
}

.text-primary:hover {
    color: var(--accent-orange) !important;
}

/* Profile Page Styles */
.profile-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    animation: fadeIn 0.6s ease-out;
}

.settings-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.settings-section h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.profile-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.api-key-input {
    font-family: monospace;
    letter-spacing: 1px;
}

.save-btn {
    background: var(--gradient);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1rem;
}

.save-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.status-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 12px;
    animation: fadeIn 0.3s ease-out;
}

.status-message.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid #10b981;
    color: #10b981;
}

.status-message.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #ef4444;
}

@media (max-width: 768px) {
    .profile-container {
        padding: 1rem;
    }
    
    .settings-section {
        padding: 1.5rem;
    }
}
