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

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #0f172a;
    --bg-light: #1e293b;
    --bg-lighter: #334155;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #475569;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-color) 0%, #1e1b4b 100%);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--bg-light);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 10;
}

.app-header h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-lighter);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-icon {
    background: transparent;
    border: 2px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-lighter);
    border-color: var(--primary-color);
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s ease;
}

.btn-close:hover {
    color: var(--danger-color);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    position: relative;
}

/* Result Display */
.result-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-light);
    padding: 3rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    text-align: center;
    min-width: 400px;
    animation: slideIn 0.5s ease;
}

.result-display h2 {
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.result-text {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-lighter);
    border-radius: 0.5rem;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* Sidebars */
.config-sidebar,
.history-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-light);
    box-shadow: var(--shadow-lg);
    transition: right 0.3s ease;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.config-sidebar.active {
    right: 0;
}

.history-sidebar {
    right: -450px;
    width: 450px;
}

.history-sidebar.active {
    right: 0;
}

.sidebar-header {
    padding: 1.5rem;
    background: var(--bg-lighter);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.5rem;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.config-section {
    margin-bottom: 2rem;
}

.config-section h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

/* Form Controls */
.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-lighter);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

/* Segment List */
.segment-list {
    margin-bottom: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.segment-item {
    background: var(--bg-lighter);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.segment-color {
    width: 40px;
    height: 40px;
    border-radius: 0.25rem;
    flex-shrink: 0;
}

.segment-info {
    flex: 1;
}

.segment-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.segment-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.segment-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-sm {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: transform 0.2s ease;
}

.btn-icon-sm:hover {
    transform: scale(1.2);
}

/* History */
.history-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.history-list {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.history-item {
    background: var(--bg-lighter);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--primary-color);
}

.history-result {
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.history-time {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.btn-history-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    z-index: 50;
}

.btn-history-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* Modal */
.modal {
    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: 200;
}

.modal-content {
    background: var(--bg-light);
    border-radius: 1rem;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.5rem;
    background: var(--bg-lighter);
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Image Upload */
.image-upload-options {
    margin-top: 0.5rem;
}

.tab-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 0.25rem;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.tab-content {
    display: none;
}

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

.image-preview {
    margin-top: 1rem;
    text-align: center;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.remaining-segments {
    position: absolute;
    bottom: -3rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-light);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-lighter);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .app-header h1 {
        font-size: 1.5rem;
    }

    .config-sidebar,
    .history-sidebar {
        width: 100%;
        right: -100%;
    }

    .result-display {
        min-width: 90%;
        padding: 2rem;
    }

    .result-text {
        font-size: 1.75rem;
    }

    .btn-history-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 50px;
        height: 50px;
    }
}

/* Auth components */
.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.35);
}

.auth-badge-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

.auth-badge-user {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.auth-modal {
    max-width: 520px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.auth-form input[type="email"],
.auth-form input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 2px solid var(--border-color);
    background: var(--bg-lighter);
    color: var(--text-color);
    font-size: 1rem;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-checkbox input[type="checkbox"] {
    margin-top: 0.2rem;
}

.auth-checkbox a {
    color: var(--primary-color);
}

.auth-message {
    margin-top: 1rem;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-weight: 600;
    display: none;
}

.auth-message.error {
    display: block;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.auth-message.success {
    display: block;
    background: rgba(34, 197, 94, 0.15);
    color: #bbf7d0;
}

.auth-message.info {
    display: block;
    background: rgba(59, 130, 246, 0.15);
    color: #bfdbfe;
}

.auth-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.auth-actions .btn {
    flex: 1;
    min-width: 120px;
}

@media (max-width: 480px) {
    .auth-form input[type="email"],
    .auth-form input[type="text"] {
        font-size: 0.95rem;
        padding: 0.65rem;
    }

    .auth-actions {
        flex-direction: column;
    }
}

