/* =============================================
   LensLesson Admin - Styles
   ============================================= */

:root {
    /* Brand Colors */
    --lens-navy: #1B4B8C;
    --lens-navy-dark: #0f2d4d;
    --lens-navy-light: #2d6cb5;
    --aperture-teal: #5BA4A4;
    --aperture-teal-light: #7bc4c4;
    --focus-green: #3D8B6E;
    
    /* Neutrals */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Status */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Spacing & Sizing */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

/* =============================================
   Layout
   ============================================= */

.admin-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--lens-navy);
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--white);
    font-weight: 700;
    font-size: 1.125rem;
}

.header-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--aperture-teal);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.header-brand img {
    height: 32px;
    width: auto;
}

.header-nav {
    display: flex;
    gap: 0.25rem;
}

.header-nav a {
    color: rgba(255,255,255,0.7);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-nav a:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.header-nav a.active {
    background: rgba(255,255,255,0.15);
    color: var(--white);
}

.header-nav svg {
    width: 18px;
    height: 18px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-user span {
    color: rgba(255,255,255,0.7);
    font-size: 0.875rem;
}

.header-user button {
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.header-user button:hover {
    background: rgba(255,255,255,0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1.5rem;
}

/* =============================================
   Quick Create Card
   ============================================= */

.quick-create {
    background: linear-gradient(135deg, var(--lens-navy) 0%, var(--lens-navy-light) 50%, var(--aperture-teal) 100%);
    border-radius: var(--radius-xl);
    padding: 2rem;
    color: var(--white);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.quick-create::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 50%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}

.quick-create h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.quick-create p {
    opacity: 0.9;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    position: relative;
}

.quick-create-form {
    display: flex;
    gap: 0.75rem;
    position: relative;
}

.quick-create-input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    background: var(--white);
    color: var(--gray-900);
}

.quick-create-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(91, 164, 164, 0.3);
}

.quick-create-input::placeholder {
    color: var(--gray-400);
}

.quick-create-select {
    padding: 0.875rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--white);
    color: var(--gray-900);
    min-width: 160px;
    cursor: pointer;
}

.quick-create-btn {
    background: var(--white);
    color: var(--lens-navy);
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    transition: all 0.2s;
}

.quick-create-btn:hover {
    background: var(--gray-100);
    transform: translateY(-1px);
}

.quick-create-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.quick-create-btn svg {
    width: 18px;
    height: 18px;
}

.quick-create-btn.loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* =============================================
   Stats Grid
   ============================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
}

.stat-card.clickable {
    cursor: pointer;
}

.stat-card.clickable:hover {
    border-color: var(--aperture-teal);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--lens-navy);
    line-height: 1.2;
}

.stat-value.warning { color: var(--warning); }
.stat-value.success { color: var(--success); }
.stat-value.info { color: var(--aperture-teal); }

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* =============================================
   Dashboard Grid
   ============================================= */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header-link {
    font-size: 0.75rem;
    color: var(--aperture-teal);
    font-weight: 500;
}

.card-header-link:hover {
    text-decoration: underline;
}

.card-content {
    padding: 1rem 1.25rem;
}

.card-empty {
    padding: 3rem 1.25rem;
    text-align: center;
    color: var(--gray-400);
}

.card-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

/* =============================================
   Pipeline Jobs
   ============================================= */

.pipeline-job {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.pipeline-job:last-child {
    border-bottom: none;
}

.job-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--aperture-teal);
    flex-shrink: 0;
}

.job-status.processing {
    animation: pulse 1.5s ease-in-out infinite;
}

.job-status.completed {
    background: var(--success);
    animation: none;
}

.job-status.failed {
    background: var(--error);
    animation: none;
}

.job-status.pending {
    background: var(--gray-300);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.9); }
}

.job-info {
    flex: 1;
    min-width: 0;
}

.job-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-step {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.job-step.success {
    color: var(--success);
}

.job-time {
    font-size: 0.75rem;
    color: var(--gray-400);
    white-space: nowrap;
}

/* =============================================
   Draft Cards
   ============================================= */

.drafts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.draft-card {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.draft-card:hover {
    border-color: var(--aperture-teal);
    box-shadow: var(--shadow);
}

.draft-image {
    width: 100px;
    height: 66px;
    border-radius: var(--radius-sm);
    background: var(--gray-200);
    flex-shrink: 0;
    overflow: hidden;
}

.draft-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.draft-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.draft-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray-900);
    line-height: 1.3;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.draft-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: auto;
}

.draft-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* =============================================
   Buttons
   ============================================= */

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

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

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

.btn-primary:hover {
    background: var(--lens-navy-dark);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

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

.btn-success:hover {
    background: #059669;
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
}

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

/* =============================================
   Forms
   ============================================= */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--aperture-teal);
    box-shadow: 0 0 0 3px rgba(91, 164, 164, 0.15);
}

.form-control::placeholder {
    color: var(--gray-400);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* =============================================
   Tables
   ============================================= */

.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: 0.025em;
}

.table tr:hover {
    background: var(--gray-50);
}

.table tr:last-child td {
    border-bottom: none;
}

/* =============================================
   Badges
   ============================================= */

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-draft {
    background: #fef3c7;
    color: #92400e;
}

.badge-published {
    background: #d1fae5;
    color: #065f46;
}

.badge-scheduled {
    background: #dbeafe;
    color: #1e40af;
}

.badge-processing {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-failed {
    background: #fee2e2;
    color: #991b1b;
}

/* =============================================
   Toast Notifications
   ============================================= */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--gray-900);
    color: var(--white);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

.toast.warning {
    background: var(--warning);
}

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

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 0.25rem;
}

.toast-close:hover {
    color: var(--white);
}

/* =============================================
   Modal
   ============================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

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

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
}

.modal-close:hover {
    color: var(--gray-600);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* =============================================
   Responsive
   ============================================= */

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Header */
    .header {
        padding: 0 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .header-brand span {
        display: none;
    }
    
    .header-nav {
        order: 3;
        width: 100%;
        justify-content: space-around;
        padding: 0.5rem 0;
        border-top: 1px solid rgba(255,255,255,0.1);
        gap: 0;
    }
    
    .header-nav a {
        flex-direction: column;
        font-size: 0.7rem;
        padding: 0.5rem;
        gap: 0.25rem;
    }
    
    .header-nav a svg {
        width: 20px;
        height: 20px;
    }
    
    .header-user button {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
    
    /* Main Content */
    .main-content {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    /* Quick Create */
    .quick-create {
        padding: 1.5rem;
    }
    
    .quick-create-form {
        flex-direction: column;
    }
    
    .quick-create-select {
        width: 100%;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    /* Draft Cards */
    .draft-card {
        flex-direction: column;
    }
    
    .draft-image {
        width: 100%;
        height: 120px;
    }
    
    /* Filter Tabs */
    .filter-tabs {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .filter-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    /* Posts Toolbar */
    .posts-toolbar {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .posts-toolbar .search-input {
        width: 100%;
    }
    
    .posts-toolbar select {
        width: 100%;
    }
    
    .toolbar-filters {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    /* Post Rows - Card Style on Mobile */
    .post-row {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
        gap: 0.75rem;
        position: relative;
    }
    
    .post-row > input[type="checkbox"] {
        position: absolute;
        top: 1rem;
        right: 1rem;
    }
    
    .post-image {
        width: 100%;
        height: 150px;
        border-radius: 8px;
    }
    
    .post-info {
        width: 100%;
    }
    
    .post-title {
        font-size: 1rem;
    }
    
    .post-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .post-actions .btn {
        flex: 1;
        min-width: 70px;
        text-align: center;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .pagination button {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }
    
    .pagination span {
        width: 100%;
        text-align: center;
        margin-top: 0.5rem;
    }
    
    /* Cards */
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .card-header h3 {
        font-size: 1rem;
    }
    
    /* Topics Grid */
    .topics-grid {
        grid-template-columns: 1fr;
    }
    
    /* Modal */
    .modal {
        width: 95%;
        max-height: 95vh;
        margin: 0.5rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Post Editor */
    .editor-grid {
        grid-template-columns: 1fr;
    }
    
    .editor-sidebar {
        order: -1;
    }
    
    /* Bulk Actions */
    .bulk-actions {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .header-nav a span {
        display: none;
    }
    
    .header-nav a {
        padding: 0.75rem;
    }
    
    .header-nav a svg {
        width: 24px;
        height: 24px;
    }
    
    .filter-tabs {
        justify-content: center;
    }
    
    .filter-tab {
        flex: 1;
        text-align: center;
        min-width: 70px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .post-actions .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
}

/* =============================================
   Utilities
   ============================================= */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-small { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
