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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #262626;
    background-color: #fafafa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #0095f6;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Navbar */
.navbar {
    background: #fff;
    border-bottom: 1px solid #dbdbdb;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 1.5rem;
    font-weight: 600;
    color: #262626;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: #262626;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background 0.2s;
}

.nav-link:hover {
    background: #f0f0f0;
    text-decoration: none;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background: #0095f6;
    color: #fff;
}

.btn-primary:hover {
    background: #0086e0;
    text-decoration: none;
}

.btn-secondary {
    background: #efefef;
    color: #262626;
}

.btn-secondary:hover {
    background: #dbdbdb;
    text-decoration: none;
}

.btn-danger {
    background: #ed4956;
    color: #fff;
}

.btn-danger:hover {
    background: #d63845;
    text-decoration: none;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

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

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

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #262626;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #0095f6;
}

.form-group .hint {
    font-size: 12px;
    color: #8e8e8e;
    margin-top: 4px;
}

/* Messages */
.error-message {
    color: #ed4956;
    margin-bottom: 15px;
    font-size: 14px;
}

.success-message {
    color: #00c853;
    margin-bottom: 15px;
    font-size: 14px;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.auth-box {
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.auth-box h2 {
    margin-bottom: 30px;
    text-align: center;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    color: #8e8e8e;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 60px 20px;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 20px;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: #8e8e8e;
    margin-bottom: 40px;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.feature {
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 12px;
    padding: 30px;
}

.feature h3 {
    margin-bottom: 10px;
}

.cta-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

/* Dashboard */
.dashboard h1 {
    margin-bottom: 30px;
}

.welcome-message {
    margin-bottom: 30px;
    color: #8e8e8e;
}

.section {
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
}

.section h2 {
    margin-bottom: 20px;
    font-size: 1.2rem;
}

/* Accounts List */
.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.account-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #fafafa;
    border-radius: 8px;
}

.account-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.account-info .page-name {
    font-size: 14px;
    color: #8e8e8e;
}

.token-expiry {
    font-size: 12px;
    color: #8e8e8e;
}

/* Action Cards */
.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.action-card {
    display: block;
    background: #fafafa;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.2s;
}

.action-card:hover {
    border-color: #0095f6;
    text-decoration: none;
}

.action-card h3 {
    margin-bottom: 8px;
    color: #262626;
}

.action-card p {
    color: #8e8e8e;
    font-size: 14px;
}

/* Post Cards */
.post-card {
    background: #fafafa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

.post-info {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.post-type {
    background: #0095f6;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.post-caption {
    color: #262626;
}

.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #8e8e8e;
}

/* Create Post Page */
.create-post {
    max-width: 600px;
    margin: 0 auto;
}

.upload-area {
    border: 2px dashed #dbdbdb;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #0095f6;
    background: #f0f8ff;
}

.upload-area input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
    cursor: grab;
    user-select: none;
    transition: opacity 0.15s, outline 0.1s, box-shadow 0.15s, transform 0.15s;
}

.preview-item:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    transform: translateY(-2px);
}

.preview-item.dragging {
    opacity: 0.35;
    cursor: grabbing;
    transform: none;
    box-shadow: none;
}

.preview-item.drag-over {
    outline: 2px solid #0095f6;
    outline-offset: 2px;
}

.preview-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.preview-item:hover .preview-remove {
    opacity: 1;
}

.preview-remove:hover {
    background: rgba(237, 73, 86, 0.9);
}

.reorder-hint {
    grid-column: 1 / -1;
    font-size: 12px;
    color: #8e8e8e;
    text-align: center;
    padding: 4px 0 0;
}

.preview-item img,
.preview-item video {
    width: 100%;
    height: 120px;
    object-fit: cover;
    pointer-events: none;
}

.preview-order {
    position: absolute;
    top: 5px;
    left: 5px;
    background: #0095f6;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.preview-name {
    display: block;
    padding: 8px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-type {
    position: absolute;
    bottom: 35px;
    right: 5px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

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

/* Posts List Page */
.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid #dbdbdb;
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
    border-color: #0095f6;
    background: #0095f6;
    color: #fff;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

@media (min-width: 768px) {
    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .posts-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1400px) {
    .posts-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

.post-item {
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
}

.post-header {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.badge-scheduled {
    background: #ffc107;
    color: #000;
}

.badge-published {
    background: #00c853;
    color: #fff;
}

.badge-failed {
    background: #ed4956;
    color: #fff;
}

.badge-publishing {
    background: #0095f6;
    color: #fff;
}

.badge-draft {
    background: #8e8e8e;
    color: #fff;
}

.badge-partial {
    background: #ff9800;
    color: #fff;
}

.badge-pending {
    background: #8e8e8e;
    color: #fff;
}

.platform-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 8px 0;
}

.platform-badge {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.platform-targets {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid #dbdbdb;
    border-radius: 6px;
    background: #fafafa;
}

.platform-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.platform-label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 180px;
    font-size: 14px;
    cursor: pointer;
}

.platform-row select {
    flex: 1;
    min-width: 200px;
}

.platform-row select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pub-list {
    margin: 10px 0;
    padding-left: 20px;
    font-size: 13px;
    text-align: left;
}

.pub-list li {
    margin: 4px 0;
}

.post-item .post-caption {
    margin-bottom: 10px;
    font-size: 12px;
    color: #262626;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-item .post-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 10px;
    font-size: 11px;
    color: #8e8e8e;
}

.post-error {
    color: #ed4956;
    font-size: 11px;
    margin-bottom: 10px;
    padding: 6px;
    background: #ffeaec;
    border-radius: 4px;
}

.post-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.post-actions .btn-small {
    font-size: 10px;
    padding: 4px 8px;
}

/* Analytics Page */
.reconnect-banner {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reconnect-banner a { color: #405de6; }

.banner-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #8e8e8e;
    padding: 0 4px;
}


.analytics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
    padding: 20px;
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 12px;
}

.summary-metric {
    text-align: center;
}

.summary-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: #262626;
}

.summary-label {
    font-size: 12px;
    color: #8e8e8e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metrics-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.metric {
    text-align: center;
    padding: 8px 4px;
    background: #fafafa;
    border-radius: 8px;
}

.metric-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
    color: #262626;
}

.metric-label {
    font-size: 11px;
    color: #8e8e8e;
}

.loading-metrics {
    color: #8e8e8e;
    font-size: 13px;
    padding: 8px 0;
}

.metric-na {
    color: #8e8e8e;
    font-size: 13px;
}

.card-actions {
    display: flex;
    gap: 10px;
}

/* Settings Page */
.info-box {
    background: #fafafa;
    border-radius: 8px;
    padding: 15px;
}

.info-box p {
    margin-bottom: 8px;
}

.info-box p:last-child {
    margin-bottom: 0;
}

.help-box {
    background: #e8f4fd;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.help-box h3 {
    margin-bottom: 15px;
    color: #262626;
}

.help-box ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.help-box li {
    margin-bottom: 8px;
}

.danger-zone {
    border-color: #ed4956;
}

.danger-zone h2 {
    color: #ed4956;
}

/* Alerts */
.alert {
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
}

/* Utilities */
.no-data {
    color: #8e8e8e;
    text-align: center;
    padding: 40px;
}

.loading {
    color: #8e8e8e;
    text-align: center;
}

.error {
    color: #ed4956;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: #8e8e8e;
    font-size: 14px;
    border-top: 1px solid #dbdbdb;
    background: #fff;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: scaleIn 0.2s ease;
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 20px;
}

.modal-icon.success {
    background: #e6f9ee;
    color: #00c853;
}

.modal h2 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: #262626;
}

.modal p {
    color: #8e8e8e;
    font-size: 14px;
    margin-bottom: 28px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

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

@keyframes scaleIn {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* Notification Toast */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    color: #fff;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.notification.success {
    background: #00c853;
}

.notification.error {
    background: #ed4956;
}

.notification.info {
    background: #0095f6;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Hamburger toggle button */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin-left: auto;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #262626;
    border-radius: 2px;
    transition: all 0.2s;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 15px;
        gap: 0;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        padding: 8px 0 4px;
        gap: 2px;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-link {
        padding: 10px 8px;
        font-size: 14px;
        border-radius: 6px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .cta-buttons {
        flex-direction: column;
    }

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

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

/* Media Source Toggle */
.media-source-toggle {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.toggle-btn {
    padding: 10px 20px;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.toggle-btn:hover {
    border-color: #0095f6;
}

.toggle-btn.active {
    background: #0095f6;
    color: #fff;
    border-color: #0095f6;
}

#url-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
}

/* Timezone info */
.timezone-info {
    color: #8e8e8e;
    font-size: 14px;
    margin-bottom: 20px;
}

.timezone-info strong {
    color: #262626;
}

/* Post media preview */
.post-media {
    position: relative;
    margin: 8px 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
}

.post-thumbnail {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.media-count {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
