:root {
    --bg-color: #fafafa;
    --surface-color: #ffffff;
    --text-color: #333333;
    --text-muted: #666666;
    --border-color: #e1e5e9;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --primary-color: #e1306c;
    --primary-gradient: linear-gradient(135deg, #e1306c, #f56040);
    --hover-bg: #f8f9fa;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-color: #ffffff;
    --text-muted: #b3b3b3;
    --border-color: #333333;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.4);
    --primary-color: #ff3040;
    --primary-gradient: linear-gradient(135deg, #ff3040, #ff6b40);
    --hover-bg: #2a2a2a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    color: var(--primary-color);
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    color: var(--text-muted);
    font-size: 1.1em;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    padding: 20px 0;
}

.post-card {
    position: relative;
    background: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
    cursor: pointer;
    aspect-ratio: 1;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.post-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.post-card:hover video.post-media {
    /* Play video on hover */
}

video.post-media {
    /* Ensure video doesn't have default controls */
    background: var(--surface-color);
}

.video-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.play-triangle {
    width: 0;
    height: 0;
    border-left: 6px solid white;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    margin-left: 2px;
}

/* Post info, caption and stats removed for Instagram-like clean design */

.loading-spinner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.spinner-container p {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.status-indicator {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    z-index: 5;
}

.status-active {
    background-color: #28a745;
}

.status-draft {
    background-color: #ffc107;
}

.hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.post-card:hover .hover-overlay {
    opacity: 1;
    pointer-events: all;
}

.action-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

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

.action-btn.manage {
    background: #007bff;
}

.action-btn.manage:hover {
    background: #0056b3;
}

.action-btn.finish {
    background: #ffc107;
    color: #212529;
}

.action-btn.finish:hover {
    background: #e0a800;
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
}

.popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.popup-window {
    width: 30%;
    min-width: 400px;
    height: 100%;
    background: white;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow-y: auto;
    box-shadow: -5px 0 20px rgba(0,0,0,0.3);
}

.popup-overlay.active .popup-window {
    transform: translateX(0);
}

.popup-header {
    background: var(--primary-color);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
}

.popup-content {
    padding: 30px;
}

.post-preview {
    background: var(--hover-bg);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 30px;
    text-align: center;
}

.post-preview img,
.post-preview video {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.post-preview p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.4;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

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

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

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

.btn-danger {
    background: #dc3545;
    color: white;
}

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

@media (max-width: 768px) {
    .popup-window {
        width: 100%;
        min-width: unset;
    }
    
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 12px;
    }
    
    .container {
        padding: 15px;
    }
}

.setup-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 40px 0;
}

.setup-card {
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 40px;
    max-width: 800px;
    width: 100%;
}

.setup-card h2 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 20px;
    font-size: 2em;
}

.setup-card > p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 40px;
    font-size: 1.1em;
}

.setup-steps {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.step {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    background: var(--hover-bg);
}

.step h3 {
    color: var(--text-color);
    margin-bottom: 15px;
    font-size: 1.3em;
}

.step p {
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.5;
}

.step a {
    color: var(--primary-color);
    text-decoration: none;
}

.step a:hover {
    text-decoration: underline;
}

.step code {
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    font-family: monospace;
    font-size: 14px;
    display: inline-block;
    margin-right: 10px;
    color: var(--text-color);
}

.copy-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.copy-btn:hover {
    background: #218838;
}

.step .form-group {
    margin-top: 20px;
}

#connectBtn {
    width: 100%;
    margin-top: 20px;
    padding: 15px;
    font-size: 16px;
}

@media (max-width: 768px) {
    .setup-card {
        padding: 30px 20px;
        margin: 0 15px;
    }
    
    .setup-steps {
        gap: 20px;
    }
    
    .step {
        padding: 20px;
    }
}

/* Floating Theme Toggle for Standalone Pages */
.floating-theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.floating-theme-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.floating-theme-btn:hover {
    transform: scale(1.1);
    background: var(--hover-bg);
}

.setup-note {
    margin-top: 15px;
    padding: 10px;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
}

/* Status step spacing to match setup steps gap */
#statusStep {
    margin-top: 30px;
}

/* Hidden state for setup sections */
.setup-hidden {
    display: none !important;
}

.setup-visible {
    display: flex !important;
    flex-direction: column;
    gap: 30px;
}

/* Mandatory Setup Overlay */
.setup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.setup-overlay .setup-container {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 0;
    min-height: auto;
}

.setup-overlay .setup-card {
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.setup-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
}

.setup-overlay-header h1 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.8em;
}

.setup-logout-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.setup-logout-btn:hover {
    background: #c82333;
}

.setup-overlay.hidden {
    display: none;
}

/* Skeleton Loading Animation */
.skeleton {
    background: linear-gradient(90deg, var(--hover-bg) 25%, var(--border-color) 50%, var(--hover-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Skeleton for post cards */
.post-card-skeleton {
    position: relative;
    background: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    aspect-ratio: 1;
}

.post-card-skeleton .skeleton-media {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--hover-bg) 25%, var(--border-color) 50%, var(--hover-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Skeleton overlay for existing post cards */
.post-card .skeleton-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--hover-bg) 25%, var(--border-color) 50%, var(--hover-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: -1;
    border-radius: inherit;
    pointer-events: none;
}

.post-card .skeleton-overlay.hidden {
    display: none;
}

/* Ensure media loads behind skeleton */
.post-card .post-media {
    position: relative;
    z-index: 0;
}

.post-card .post-media.loaded {
    z-index: 2;
}
