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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* Header */
.header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
}

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

/* Main Content */
.main-content {
    padding: 2rem 0;
    min-height: calc(100vh - 120px);
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-container {
    flex: 1;
    min-width: 250px;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    transition: var(--transition);
}

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

.filter-container {
    display: flex;
    gap: 0.75rem;
}

.category-filter,
.sort-select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    background-color: white;
    cursor: pointer;
    transition: var(--transition);
}

.category-filter:focus,
.sort-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Data Controls */
.data-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* Prompts Grid */
.prompts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Prompt Card */
.prompt-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.prompt-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.prompt-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    margin-right: 0.5rem;
}

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

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: var(--text-primary);
}

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

.prompt-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.prompt-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.category-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.prompt-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    padding: 0.25rem 0.5rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius);
    font-size: 0.75rem;
}

.prompt-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.use-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.copy-btn {
    padding: 0.5rem 1rem;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    background-color: #059669;
}

.copy-btn.copied {
    background-color: var(--secondary-color);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    color: var(--text-secondary);
}

.empty-state h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

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

/* Form */
#promptForm {
    padding: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    transition: var(--transition);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

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

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background-color: var(--text-primary);
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
    z-index: 2000;
    max-width: 300px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

.toast.error {
    background-color: var(--danger-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-title {
        font-size: 1.25rem;
    }

    .controls {
        flex-direction: column;
    }

    .filter-container {
        width: 100%;
    }

    .category-filter,
    .sort-select {
        flex: 1;
    }

    .prompts-grid {
        grid-template-columns: 1fr;
    }

    .data-controls {
        flex-direction: column;
    }

    .data-controls .btn {
        width: 100%;
    }

    .toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .header .container {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .btn {
        width: 100%;
    }
}

/* ===========================
   V2 STYLES
   =========================== */

/* Dark Mode Variables */
[data-theme="dark"] {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --secondary-color: #94a3b8;
    --danger-color: #f87171;
    --success-color: #34d399;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Smooth theme transition */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header Updates for V2 */
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.version-badge {
    font-size: 0.75rem;
    background: var(--success-color);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
    vertical-align: middle;
}

/* Sync Status */
.sync-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.sync-icon {
    font-size: 0.625rem;
    color: var(--success-color);
    animation: pulse 2s ease-in-out infinite;
}

.sync-status.syncing .sync-icon {
    color: var(--primary-color);
    animation: spin 1s linear infinite;
}

.sync-status.offline .sync-icon {
    color: var(--secondary-color);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Auth Components */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-block-mobile {
    width: 100%;
}

/* Auth Banner */
.auth-banner {
    background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
    color: white;
    padding: 1rem 0;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.banner-icon {
    font-size: 1.5rem;
}

.banner-text {
    flex: 1;
    min-width: 250px;
}

.banner-text strong {
    display: block;
    margin-bottom: 0.25rem;
}

.banner-text span {
    font-size: 0.875rem;
    opacity: 0.9;
}

.btn-link {
    background: none;
    border: none;
    color: white;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.875rem;
    opacity: 0.8;
}

.btn-link:hover {
    opacity: 1;
}

/* App Layout with Sidebar */
.app-layout {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 200px);
}

.folders-sidebar {
    width: 260px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    position: sticky;
    top: 160px;
    height: calc(100vh - 160px);
    overflow-y: auto;
}

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

.sidebar-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.nav-item:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--bg-color);
    color: var(--primary-color);
    font-weight: 600;
}

.nav-item .count {
    margin-left: auto;
    font-size: 0.75rem;
    background-color: var(--border-color);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0.5rem 1.5rem;
}

.folders-list {
    padding: 0.5rem 0;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: var(--transition);
    position: relative;
}

.folder-item:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.folder-item.active {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-weight: 600;
}

.folder-icon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.folder-actions {
    display: none;
    margin-left: auto;
    gap: 0.25rem;
}

.folder-item:hover .folder-actions {
    display: flex;
}

.main-container {
    flex: 1;
    min-width: 0;
}

/* Stats Modal */
.stats-container {
    padding: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

.stats-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.top-prompts-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.top-prompt-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--bg-color);
    border-radius: var(--radius);
}

.top-prompt-title {
    font-weight: 600;
    color: var(--text-primary);
}

.top-prompt-uses {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.category-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.category-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.category-name {
    min-width: 100px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.category-progress {
    flex: 1;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 9999px;
    overflow: hidden;
}

.category-progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.category-count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Folder Modal */
.modal-small {
    max-width: 400px;
}

.color-picker {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.color-option {
    cursor: pointer;
}

.color-option input[type="radio"] {
    display: none;
}

.color-swatch {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid transparent;
    transition: var(--transition);
}

.color-option input[type="radio"]:checked + .color-swatch {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--card-bg);
}

/* Share Modal */
.share-container {
    padding: 1.5rem;
}

.share-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group .form-input {
    flex: 1;
}

.share-stats {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* Checkbox Label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

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

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    z-index: 999;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

/* Prompt Card Updates for V2 */
.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.star-btn.starred {
    color: #fbbf24;
}

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

.share-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.share-btn:hover {
    color: var(--text-primary);
}

/* Responsive Updates for V2 */
@media (max-width: 1024px) {
    .folders-sidebar {
        width: 220px;
    }
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        align-items: stretch;
    }

    .header-left,
    .header-right {
        justify-content: space-between;
    }

    .app-layout {
        flex-direction: column;
    }

    .folders-sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .banner-content {
        flex-direction: column;
        text-align: center;
    }

    .banner-icon {
        font-size: 2rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .fab {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .user-profile {
        flex-direction: column;
        gap: 0.5rem;
    }

    .user-name {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading State */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Empty Folder State */
.empty-folder {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-folder svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

