/* ===================================================================
   VideoPost — Clean, Modern, Mobile-First CSS
   =================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-bg: #f5f7fa;
    --color-surface: #ffffff;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-success: #16a34a;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* --- Header --- */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 1.2rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    text-decoration: none;
    color: var(--color-text-muted);
    font-weight: 500;
    transition: color var(--transition);
}

.nav-link:hover {
    color: var(--color-primary);
}

.btn-create {
    background: var(--color-primary);
    color: white !important;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: background var(--transition);
}

.btn-create:hover {
    background: var(--color-primary-hover);
}

/* --- Footer --- */
.site-footer {
    margin-top: auto;
    padding: 2rem 0;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--color-border);
}

/* --- Alerts --- */
.alert {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1.4;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-edit {
    background: #dbeafe;
    color: #1d4ed8;
}

.btn-edit:hover {
    background: #bfdbfe;
}

.btn-delete {
    background: #fee2e2;
    color: var(--color-danger);
}

.btn-delete:hover {
    background: #fecaca;
}

.btn-page {
    background: var(--color-surface);
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

.btn-page:hover {
    border-color: var(--color-primary);
}

/* --- Post Grid --- */
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0;
}

.post-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-image-link {
    display: block;
    position: relative;
    overflow: hidden;
}

.card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform var(--transition);
}

.post-card:hover .card-image {
    transform: scale(1.03);
}

.card-body {
    padding: 1rem 1.25rem;
}

.card-description {
    font-size: 0.95rem;
    color: var(--color-text);
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.click-count {
    font-weight: 500;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.inline-form {
    display: inline;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 2rem 0;
}

.page-info {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h2 {
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.empty-state p {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

/* --- Form Pages --- */
.form-page {
    max-width: 680px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.page-title {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

/* --- Upload Area --- */
.upload-area {
    position: relative;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--transition);
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area:hover {
    border-color: var(--color-primary);
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.upload-placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
}

.upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.upload-placeholder small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
}

/* --- Image Preview --- */
.preview-container {
    position: relative;
    width: 100%;
}

.image-preview {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
}

.preview-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

.overlay-icon {
    width: 20%;
    max-width: 80px;
    height: auto;
    opacity: 0.9;
}

/* --- Current Thumbnail (Edit page) --- */
.current-thumbnail {
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.edit-preview-image {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
}

/* --- Style Picker --- */
.style-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.style-option {
    position: relative;
}

.style-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.style-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.style-label:hover {
    border-color: var(--color-primary);
    background: #f8f7ff;
}

.style-radio:checked + .style-label {
    border-color: var(--color-primary);
    background: #eef2ff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.style-preview-box {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    background: #1a1a2e;
    border-radius: var(--radius-sm);
}

.style-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.style-name {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

/* --- Error Page --- */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-code {
    font-size: 5rem;
    font-weight: 800;
    color: var(--color-primary);
    opacity: 0.3;
}

.error-title {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.error-message {
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

/* --- Duration & Progress Slider --- */
.duration-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.duration-field {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.form-input-short {
    width: 80px;
    text-align: center;
}

.duration-separator {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-muted);
    margin-bottom: 1.2rem;
}

.progress-slider-container {
    position: relative;
    padding: 0.5rem 0;
}

.progress-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff0000;
    cursor: grab;
    margin-top: -5px;
}

.progress-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff0000;
    cursor: grab;
    border: none;
}

.progress-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
}

.progress-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
}

.progress-preview-bar {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    margin-top: 0.75rem;
    background: #e5e7eb;
}

.progress-preview-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #ff0000;
    border-radius: 3px;
    transition: width 0.1s ease;
}

.progress-preview-dot {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: #ff0000;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    transition: left 0.1s ease;
}

.progress-time-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 600;
    font-family: monospace;
}

/* --- Share Buttons --- */
.card-share {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.share-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

.btn-share {
    font-size: 0.72rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: opacity var(--transition), transform var(--transition);
}

.btn-share:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.btn-download {
    background: #16a34a;
    color: white;
    text-decoration: none;
}

.btn-download:hover {
    background: #15803d;
    transform: translateY(-1px);
}

.btn-copy {
    background: #6b7280;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    text-decoration: none;
}

.btn-copy:hover {
    transform: translateY(-1px);
}

.btn-copy-fb {
    background: #1877f2;
}

.btn-copy-fb:hover {
    background: #1565c0;
}

.btn-copy-tw {
    background: #0f1419;
}

.btn-copy-tw:hover {
    background: #333;
}

.btn-copy-tt {
    background: #010101;
    border: 1px solid #fe2c55;
    color: #fe2c55;
}

.btn-copy-tt:hover {
    background: #1a1a1a;
}

.btn-copy-wa {
    background: #25d366;
    color: white;
    text-decoration: none;
}

.btn-copy-wa:hover {
    background: #1da851;
}

.btn-copy-desc {
    background: #6b7280;
}

.btn-copy-desc:hover {
    background: #4b5563;
}

.btn-copied {
    background: #16a34a !important;
    color: white !important;
    border-color: #16a34a !important;
}

.btn-facebook {
    background: #1877f2;
    color: white;
}

.btn-twitter {
    background: #0f1419;
    color: white;
}

.btn-tiktok {
    background: #010101;
    color: #fe2c55;
    border: 1px solid #fe2c55;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .post-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .header-content {
        height: 56px;
    }

    .logo {
        font-size: 1.25rem;
    }

    .form-page {
        margin: 1rem auto;
        padding: 1.25rem;
    }

    .page-title {
        font-size: 1.4rem;
    }

    .style-picker {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }

    .card-image {
        height: 180px;
    }

    .card-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}
