/*
CHANGE LOG
File: /var/www/memory_system/static/base.css
Document Type: CSS Stylesheet
Purpose: Base styling for Memory System site-wide elements
Main App: memory_app.py
Context: Core styles for base.html, navbar, footer, and common components
Dependencies: None
Version History:
2025-08-18 v1.1 - Updated main content to 80vw width, centered search section with 800px max-width, added comprehensive pagination and mobile responsiveness
2025-08-17 v1.0 - Extracted from base.html with unique class names and freemium support
*/

/* =================================
   CSS VARIABLES
   ================================= */

:root {
    /* Colors */
    --base-primary: #2563eb;
    --base-primary-hover: #1d4ed8;
    --base-secondary: #64748b;
    --base-success: #059669;
    --base-danger: #dc2626;
    --base-warning: #d97706;
    --base-light-gray: #f8fafc;
    --base-medium-gray: #e2e8f0;
    --base-dark-gray: #1e293b;
    --base-border: #e2e8f0;
    --base-text: #0f172a;
    --base-text-muted: #64748b;
    --base-body-bg: #f8fafc;
    --base-white: #ffffff;
    
    /* Shadows */
    --base-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --base-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --base-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Radius */
    --base-radius: 0.5rem;
    --base-radius-sm: 0.25rem;
    --base-radius-lg: 0.75rem;
    
    /* Freemium Colors */
    --base-tier-free: #17a2b8;
    --base-tier-premium: #ffd700;
    --base-tier-upgrade: #e74c3c;
}

/* =================================
   BASE STYLES
   ================================= */

* {
    box-sizing: border-box;
}

.base-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--base-body-bg);
    color: var(--base-text);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* =================================
   NAVBAR STYLES
   ================================= */

.base-navbar {
    background-color: var(--base-white);
    border-bottom: 1px solid var(--base-border);
    padding: 1rem 0;
    box-shadow: var(--base-shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.base-navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.base-nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--base-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.base-nav-brand:hover {
    text-decoration: none;
    color: var(--base-primary-hover);
}

.base-brand-icon {
    font-size: 1.8rem;
}

.base-nav-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--base-text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    background: var(--base-light-gray);
    border-radius: var(--base-radius-sm);
    border: 1px solid var(--base-border);
}

.base-user-info {
    font-weight: 600;
    color: var(--base-text);
}

.base-tier-badge {
    padding: 0.25rem 0.5rem;
    border-radius: var(--base-radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.base-tier-free {
    background: var(--base-tier-free);
    color: white;
}

.base-tier-premium {
    background: linear-gradient(135deg, var(--base-tier-premium), #ffed4e);
    color: #212529;
}

.base-nav-links {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.5rem;
    align-items: center;
}

.base-nav-link {
    color: var(--base-text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--base-radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.base-nav-link:hover {
    color: var(--base-primary);
    background-color: var(--base-light-gray);
    text-decoration: none;
}

.base-nav-dashboard {
    background: var(--base-tier-free);
    color: white;
}

.base-nav-dashboard:hover {
    background: #138496;
    color: white;
}

.base-nav-upgrade {
    background: var(--base-tier-upgrade);
    color: white;
}

.base-nav-upgrade:hover {
    background: #c0392b;
    color: white;
}

.base-nav-download {
    background: var(--base-tier-premium);
    color: #212529;
}

.base-nav-download:hover {
    background: #e6c200;
    color: #212529;
}

.base-nav-logout {
    color: var(--base-danger);
}

.base-nav-logout:hover {
    background: var(--base-danger);
    color: white;
}

/* Mobile Menu */
.base-mobile-toggle {
    display: none;
    flex-direction: column;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    gap: 0.25rem;
}

.base-hamburger {
    width: 25px;
    height: 3px;
    background: var(--base-text);
    transition: all 0.3s;
    border-radius: 2px;
}

.base-mobile-toggle-open .base-hamburger:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.base-mobile-toggle-open .base-hamburger:nth-child(2) {
    opacity: 0;
}

.base-mobile-toggle-open .base-hamburger:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* =================================
   MAIN CONTENT STYLES
   ================================= */

.base-site-content {
    flex: 1;
    max-width: 80vw;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

.base-page-header {
    margin-bottom: 2rem;
    text-align: center;
}

.base-page-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--base-text);
}

.base-page-header p {
    font-size: 1.125rem;
    color: var(--base-text-muted);
    margin: 0;
}

/* =================================
   CARD STYLES
   ================================= */

.base-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.base-nav-card {
    background: var(--base-white);
    border: 1px solid var(--base-border);
    border-radius: var(--base-radius-lg);
    padding: 2rem;
    text-decoration: none;
    color: var(--base-text);
    transition: all 0.3s ease;
    display: block;
    box-shadow: var(--base-shadow-sm);
}

.base-nav-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--base-shadow-lg);
    border-color: var(--base-primary);
    text-decoration: none;
    color: var(--base-text);
}

.base-nav-card h3 {
    margin: 0 0 0.75rem;
    color: var(--base-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.base-nav-card p {
    margin: 0;
    color: var(--base-text-muted);
    line-height: 1.5;
}

/* =================================
   BUTTON STYLES
   ================================= */

.base-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    border: 1px solid transparent;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    border-radius: var(--base-radius);
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.5rem;
    white-space: nowrap;
}

.base-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.base-btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

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

.base-btn-primary:hover {
    background-color: var(--base-primary-hover);
    border-color: var(--base-primary-hover);
    color: var(--base-white);
    text-decoration: none;
}

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

.base-btn-secondary:hover {
    background-color: var(--base-light-gray);
    color: var(--base-text);
    text-decoration: none;
}

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

.base-btn-danger:hover {
    background-color: #b91c1c;
    border-color: #b91c1c;
    color: var(--base-white);
    text-decoration: none;
}

/* =================================
   FORM STYLES
   ================================= */

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

.base-form-control {
    display: block;
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--base-text);
    background-color: var(--base-white);
    border: 1px solid var(--base-border);
    border-radius: var(--base-radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.base-form-control:focus {
    outline: none;
    border-color: var(--base-primary);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.base-content-textarea {
    min-height: 200px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    resize: vertical;
}

.base-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--base-text);
}

.base-form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--base-text-muted);
}

.base-form-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* =================================
   ALERT STYLES
   ================================= */

.base-flash-messages {
    margin-bottom: 20px;
}

.base-alert {
    padding: 12px 16px;
    border-radius: var(--base-radius);
    margin-bottom: 10px;
    position: relative;
    font-weight: 500;
}

.base-alert-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.base-alert-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.base-alert-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.base-alert-close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
}

.base-alert-close:hover {
    opacity: 1;
}

/* =================================
   FOOTER STYLES
   ================================= */

.base-footer {
    background-color: var(--base-white);
    border-top: 1px solid var(--base-border);
    margin-top: auto;
    padding: 3rem 0 1rem 0;
}

.base-footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

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

.base-footer-section {
    display: flex;
    flex-direction: column;
}

.base-footer-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--base-text);
    margin: 0 0 1rem 0;
}

.base-footer-description {
    color: var(--base-text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.base-footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.base-footer-link {
    color: var(--base-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.base-footer-link:hover {
    color: var(--base-primary);
    text-decoration: none;
}

.base-footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 2rem;
    border-top: 1px solid var(--base-border);
    flex-wrap: wrap;
    gap: 1rem;
}

.base-footer-copyright {
    color: var(--base-text-muted);
    font-size: 0.875rem;
}

.base-footer-copyright p {
    margin: 0;
}

.base-footer-version {
    font-size: 0.8rem;
    opacity: 0.8;
}

.base-footer-upgrade {
    display: flex;
    align-items: center;
}

.base-footer-upgrade-btn {
    background: var(--base-tier-upgrade);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--base-radius);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s;
}

.base-footer-upgrade-btn:hover {
    background: #c0392b;
    text-decoration: none;
    color: white;
}

/* =================================
   SEARCH AND CONVERSATION STYLES
   ================================= */

.base-search-section {
    background: var(--base-white);
    border: 1px solid var(--base-border);
    border-radius: var(--base-radius-lg);
    padding: 1.5rem;
    margin: 0 auto 2rem auto;
    box-shadow: var(--base-shadow-sm);
    max-width: 800px;
    width: 100%;
}

.base-search-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

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

.base-source-filter {
    min-width: 150px;
}

.base-results-info {
    margin: 0 auto 1rem auto;
    color: var(--base-text-muted);
    font-size: 0.875rem;
    text-align: center;
    max-width: 800px;
}

.base-conversations-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.base-conversation-card {
    background: var(--base-white);
    border: 1px solid var(--base-border);
    border-radius: var(--base-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--base-shadow-sm);
    transition: box-shadow 0.2s;
}

.base-conversation-card:hover {
    box-shadow: var(--base-shadow-md);
}

.base-conv-header {
    margin-bottom: 1rem;
}

.base-conv-title {
    margin: 0 0 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.base-conv-title a {
    color: var(--base-primary);
    text-decoration: none;
}

.base-conv-title a:hover {
    text-decoration: underline;
}

.base-conv-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--base-text-muted);
    flex-wrap: wrap;
}

.base-conv-source {
    background: var(--base-light-gray);
    padding: 0.25rem 0.5rem;
    border-radius: var(--base-radius-sm);
    font-weight: 500;
}

.base-conv-summary {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--base-light-gray);
    border-radius: var(--base-radius);
    font-size: 0.875rem;
}

.base-conv-preview {
    margin-bottom: 1rem;
    color: var(--base-text-muted);
    line-height: 1.5;
}

.base-conv-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* =================================
   PAGINATION STYLES
   ================================= */

.base-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2rem 0;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.base-pagination-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    min-width: 2.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--base-text-muted);
    background: var(--base-white);
    border: 1px solid var(--base-border);
    border-radius: var(--base-radius);
    text-decoration: none;
    transition: all 0.2s;
}

.base-pagination-link:hover {
    color: var(--base-primary);
    border-color: var(--base-primary);
    background: var(--base-light-gray);
    text-decoration: none;
}

.base-pagination-link.base-pagination-active {
    color: var(--base-white);
    background: var(--base-primary);
    border-color: var(--base-primary);
}

.base-pagination-link.base-pagination-disabled {
    color: var(--base-medium-gray);
    background: var(--base-light-gray);
    border-color: var(--base-medium-gray);
    cursor: not-allowed;
    pointer-events: none;
}

.base-pagination-info {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: var(--base-text-muted);
    margin: 0 1rem;
    white-space: nowrap;
}

.base-pagination-prev,
.base-pagination-next {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.base-pagination-ellipsis {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--base-text-muted);
    font-weight: 500;
}

/* =================================
   UTILITY CLASSES
   ================================= */

.base-text-center { text-align: center; }
.base-text-muted { color: var(--base-text-muted); }
.base-mb-0 { margin-bottom: 0; }
.base-mb-1 { margin-bottom: 0.5rem; }
.base-mb-2 { margin-bottom: 1rem; }
.base-mb-3 { margin-bottom: 1.5rem; }
.base-mt-2 { margin-top: 1rem; }
.base-mt-3 { margin-top: 1.5rem; }

.base-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--base-text-muted);
}

.base-empty-state h3 {
    margin: 0 0 0.5rem;
    color: var(--base-text);
}

.base-loading-spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--base-border);
    border-top: 2px solid var(--base-primary);
    border-radius: 50%;
    animation: base-spin 1s linear infinite;
}

@keyframes base-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.base-hidden { display: none !important; }
.base-visible { display: block !important; }

.base-flex { display: flex; }
.base-flex-wrap { flex-wrap: wrap; }
.base-flex-column { flex-direction: column; }
.base-flex-center { justify-content: center; align-items: center; }
.base-flex-between { justify-content: space-between; }
.base-flex-1 { flex: 1; }

.base-w-full { width: 100%; }
.base-h-full { height: 100%; }

/* =================================
   RESPONSIVE STYLES
   ================================= */

@media (max-width: 768px) {
    /* Hide desktop nav links on mobile */
    .base-nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--base-white);
        border-top: 1px solid var(--base-border);
        box-shadow: var(--base-shadow-md);
        flex-direction: column;
        padding: 1rem;
        gap: 0.25rem;
    }
    
    .base-nav-links-open {
        display: flex;
    }
    
    /* Show mobile toggle */
    .base-mobile-toggle {
        display: flex;
    }
    
    /* Adjust navbar container for mobile */
    .base-navbar-container {
        flex-wrap: wrap;
    }
    
    .base-nav-status {
        order: 3;
        width: 100%;
        margin-top: 1rem;
        justify-content: center;
    }
    
    /* Adjust main content for mobile */
    .base-site-content {
        max-width: 95vw;
        padding: 1rem 0.5rem;
    }
    
    /* Stack page header text */
    .base-page-header h1 {
        font-size: 2rem;
    }
    
    /* Adjust card grid for mobile */
    .base-card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Adjust search section for mobile */
    .base-search-section {
        max-width: 100%;
        margin: 0 0 2rem 0;
        padding: 1rem;
    }
    
    /* Stack search row items */
    .base-search-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .base-search-input,
    .base-source-filter {
        min-width: auto;
        width: 100%;
    }
    
    /* Adjust results info for mobile */
    .base-results-info {
        max-width: 100%;
        margin: 0 0 1rem 0;
    }
    
    /* Adjust conversation card padding */
    .base-conversation-card {
        padding: 1rem;
    }
    
    /* Stack conversation meta items */
    .base-conv-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    /* Stack form actions */
    .base-form-actions {
        flex-direction: column;
    }
    
    .base-form-actions .base-btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Adjust footer for mobile */
    .base-footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .base-footer-bottom {
        flex-direction: column;
        text-align: center;
    }
    
    /* Adjust pagination for mobile */
    .base-pagination {
        gap: 0.25rem;
    }
    
    .base-pagination-link {
        min-width: 2rem;
        padding: 0.375rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .base-pagination-info {
        order: -1;
        width: 100%;
        justify-content: center;
        margin: 0 0 1rem 0;
    }
}

@media (max-width: 480px) {
    .base-site-content {
        padding: 1rem 0.5rem;
    }
    
    .base-navbar-container {
        padding: 0 0.5rem;
    }
    
    .base-footer-container {
        padding: 0 0.5rem;
    }
    
    .base-nav-brand {
        font-size: 1.25rem;
    }
    
    .base-brand-icon {
        font-size: 1.5rem;
    }
    
    .base-page-header h1 {
        font-size: 1.75rem;
    }
    
    .base-page-header p {
        font-size: 1rem;
    }
    
    .base-nav-card {
        padding: 1.5rem;
    }
}
