/* Mobile-First CSS Design */
:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --border-radius: 12px;
    
    /* Light theme variables */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --comment-bg: #f8f9fa;
    --reply-bg: #e9ecef;
}

/* Dark theme variables */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-gradient: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    --comment-bg: #334155;
    --reply-bg: #475569;
}

/* Base Styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Brand Tagline */
.tagline {
    font-size: 0.65rem;
    font-style: italic;
    font-weight: normal;
    font-family: 'Brush Script MT', 'Lucida Handwriting', 'Segoe Print', cursive;
    opacity: 0.85;
    line-height: 1.1;
    margin-top: -2px;
}

/* User Avatar */
.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent-color);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

/* Family Member Circles */
.family-circle {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    transition: background 0.3s ease;
}

.member-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 auto 0.5rem;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.member-avatar:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.member-avatar.active {
    ring: 4px solid var(--accent-color);
    transform: scale(1.1);
}

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

/* Post Cards */
.post-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    overflow: hidden;
    transition: transform 0.2s ease, background 0.3s ease;
}

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

.post-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.post-author {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.post-author-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.post-content {
    padding: 1.5rem;
}

.post-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.post-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.post-text {
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* Photo Grid */
.photo-grid {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.photo-grid.single {
    grid-template-columns: 1fr;
}

.photo-grid.double {
    grid-template-columns: 1fr 1fr;
}

.photo-grid.multiple {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.photo-item:hover img {
    transform: scale(1.05);
}

.photo-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.photo-item:hover .photo-overlay {
    opacity: 1;
}

/* Tags */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    background: #e0e7ff;
    color: var(--primary-color);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Like Button */
.like-btn {
    transition: all 0.2s ease;
    text-decoration: none !important;
}

.like-btn:hover {
    transform: scale(1.1);
}

.like-btn.text-danger {
    color: #dc3545 !important;
}

.like-btn.text-danger:hover {
    color: #c82333 !important;
}

/* Comments */
.comment-content {
    background-color: var(--comment-bg);
    transition: background-color 0.3s ease;
}

.reply-content {
    background-color: var(--reply-bg);
    transition: background-color 0.3s ease;
}

.reply-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
}

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

.comment-text, .reply-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
}

.replies {
    border-left: 2px solid var(--border-color);
    padding-left: 1rem;
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    border-radius: var(--border-radius);
    font-weight: 600;
    padding: 0.75rem 1.5rem;
}

.btn-primary:hover {
    background: #4f46e5;
    border-color: #4f46e5;
}

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

.btn-floating:hover {
    transform: scale(1.1);
    background: #d97706;
}

/* Forms */
.form-control {
    border-radius: var(--border-radius);
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    transition: border-color 0.2s ease, background 0.3s ease, color 0.3s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* Form labels */
.form-label {
    color: var(--text-primary);
    font-weight: 600;
}

/* Select and textarea */
select.form-control,
select.form-select,
textarea.form-control {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

/* Photo Upload Preview */
#photo-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.photo-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview-remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
}

.photo-preview-item.main-photo {
    border-color: var(--accent-color);
    border-width: 3px;
}

.photo-preview-item.main-photo::after {
    content: 'MAIN';
    position: absolute;
    bottom: 0.25rem;
    left: 0.25rem;
    background: var(--accent-color);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
}

/* Responsive Design */
@media (min-width: 768px) {
    .member-avatar {
        width: 100px;
        height: 100px;
        font-size: 1.75rem;
    }
    
    .photo-grid.multiple {
        grid-template-columns: 2fr 1fr 1fr;
        grid-template-rows: 1fr 1fr;
    }
    
    .photo-grid.multiple .photo-item:first-child {
        grid-row: 1 / 3;
    }
    
    .btn-floating {
        bottom: 3rem;
        right: 3rem;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1200px;
    }
    
    .post-card {
        margin-bottom: 2.5rem;
    }
    
    .family-circle {
        padding: 2rem;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Loading States */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Dark Mode Toggle */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.theme-toggle:hover {
    color: var(--primary-color);
}

/* Card backgrounds */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.card-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s ease, border-color 0.3s ease;
}

/* Bootstrap overrides for dark mode */
.dropdown-menu {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.dropdown-item {
    color: var(--text-primary);
    transition: color 0.3s ease;
}

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

.dropdown-divider {
    border-color: var(--border-color);
}

.badge {
    transition: background 0.3s ease;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Modal dark mode */
.modal-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
}

/* Search */
.search-suggestion:hover {
    background: var(--bg-tertiary) !important;
}

#searchSuggestions {
    background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

.search-suggestion {
    transition: background 0.2s ease;
}

mark {
    background: var(--accent-color);
    color: white;
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

/* Comment editing */
.comment-edited {
    font-style: italic;
    color: var(--text-muted);
}

/* Photo gallery counter */
#photoCounter {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 10;
}

/* Mobile photo counter for dashboard */
.photo-counter-mobile {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 5;
    display: none;
}

/* Show mobile counter only on mobile */
@media (max-width: 767px) {
    .photo-counter-mobile {
        display: block;
    }
    
    .photo-grid {
        touch-action: pan-y;
        user-select: none;
    }
}

.comment-edit-btn {
    color: var(--text-muted) !important;
    text-decoration: none !important;
    font-size: 0.8rem;
}

.comment-edit-btn:hover {
    color: var(--primary-color) !important;
}

.comment-edit-form textarea {
    resize: vertical;
    min-height: 60px;
}

/* Mobile form fixes */
@media (max-width: 767px) {
    .form-control, .form-select, input, textarea, select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }
    
    textarea.form-control, textarea {
        resize: none;
        overflow-wrap: break-word;
        word-wrap: break-word;
        min-height: 100px;
    }
    
    /* Override cols attribute on mobile */
    textarea[cols] {
        width: 100% !important;
        max-width: 100% !important;
        cols: unset !important;
    }
    
    .container-fluid, .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        overflow-x: hidden;
    }
    
    .card-body {
        padding: 1rem !important;
    }
    
    .row {
        margin-left: 0;
        margin-right: 0;
    }
    
    .col-12, .col-lg-8 {
        padding-left: 0;
        padding-right: 0;
    }
    
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }
    
    .photo-upload-area {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
    }
}

/* Input groups and alerts */
.input-group-text {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.alert {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}