/**
 * AI Pulse Newsletter v2 - Styles
 * Clean, mobile-first design
 */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #f3f4f6;
    --white: #ffffff;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

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

/* Header */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.role-badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: var(--white);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    margin: 1rem;
    text-align: center;
}

.login-box h1 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-box p {
    color: var(--text-light);
    margin-bottom: 2rem;
}

/* Role Selection */
.role-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1rem;
    max-width: 600px;
    margin: 2rem auto;
}

.role-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text);
}

.role-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.role-card .icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.role-card h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.role-card p {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="password"],
input[type="url"],
textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

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

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

.btn-secondary {
    background: var(--white);
    color: var(--text);
    border: 2px solid var(--border);
}

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

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
}

.card-body {
    padding: 1.25rem;
}

/* Article Items (for Editor swipe) */
.article-list {
    padding: 1rem;
}

.article-item {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
    position: relative;
    transition: transform 0.3s, opacity 0.3s;
    touch-action: pan-y;
    user-select: none;
}

.article-item.swiping {
    transition: none;
}

.article-item.swiped-right {
    transform: translateX(100%);
    opacity: 0;
}

.article-item h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.article-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-light);
}

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

.article-actions .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Swipe indicator */
.swipe-hint {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--success);
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.article-item.swiping .swipe-hint {
    opacity: 1;
}

/* Newsletter Preview */
.newsletter-preview {
    background: var(--white);
    padding: 2rem;
    max-width: 700px;
    margin: 0 auto;
}

.newsletter-preview h1 {
    color: var(--primary);
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.newsletter-date {
    color: var(--text-light);
    margin-bottom: 2rem;
}

.category-section {
    margin-bottom: 2rem;
}

.category-section h2 {
    color: var(--primary);
    font-size: 1.25rem;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.newsletter-item {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.newsletter-item strong {
    color: var(--text);
}

.newsletter-item .source {
    color: var(--text-light);
}

.newsletter-item a {
    color: var(--primary);
}

/* Top 5 Section for Busy Leaders */
.top-five-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.top-five-section h2 {
    color: var(--primary);
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    border-bottom: none;
    padding-bottom: 0;
}

.top-five-intro {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    font-style: italic;
}

.top-five-list {
    list-style: decimal;
    padding-left: 1.5rem;
    margin: 0;
}

.top-five-item {
    margin-bottom: 0.875rem;
    line-height: 1.5;
}

.top-five-item strong a {
    color: var(--primary);
    text-decoration: none;
}

.top-five-item strong a:hover {
    text-decoration: underline;
}

.top-five-source {
    font-size: 0.875rem;
    color: var(--text-light);
}

.top-five-summary {
    font-size: 0.875rem;
    color: var(--text);
}

.section-divider {
    border: none;
    border-top: 2px solid var(--border);
    margin: 2rem 0 2.5rem 0;
}

/* Messages */
.message {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.message-success {
    background: #d1fae5;
    color: #065f46;
}

.message-error {
    background: #fee2e2;
    color: #991b1b;
}

.message-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Result Display */
.result-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 1rem 0;
    border-left: 4px solid var(--success);
}

.result-card h3 {
    margin-bottom: 0.5rem;
}

.result-card .meta {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.result-card .summary {
    background: var(--bg);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.result-card .category {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

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

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Source List */
.source-list {
    padding: 1rem;
}

.source-item {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.source-item .name {
    font-weight: 600;
}

.source-item .url {
    font-size: 0.8125rem;
    color: var(--text-light);
}

/* Actions Bar */
.actions-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.actions-bar .btn {
    flex: 1;
    max-width: 200px;
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Responsive */
@media (max-width: 600px) {
    .role-grid {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-direction: column;
        gap: 0.5rem;
    }

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

    .actions-bar .btn {
        max-width: none;
    }
}

/* Edit Mode Controls */
.item-controls {
    display: none;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
    flex-wrap: wrap;
}

.edit-mode .item-controls {
    display: flex;
}

.edit-mode .newsletter-item {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--white);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-icon-danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: #fee2e2;
}

.btn-icon-star {
    font-size: 1.125rem;
    color: var(--text-light);
}

.btn-icon-star:hover {
    border-color: #eab308;
    color: #eab308;
    background: #fefce8;
}

.btn-icon-star.active {
    color: #eab308;
    border-color: #eab308;
    background: #fef9c3;
}

.top-five-count {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-light);
}

.category-select {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    cursor: pointer;
}

.category-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Inline Edit Form */
.item-edit-form {
    margin-top: 0.75rem;
}

.item-edit-form .edit-summary {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    font-size: 0.9375rem;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

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

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

/* Add Item Section (edit mode only) */
.add-item-section {
    display: none;
    margin-bottom: 2rem;
}

.edit-mode .add-item-section {
    display: block;
}

.btn-add-item {
    width: 100%;
    padding: 1rem;
    font-size: 1.125rem;
    background: var(--success);
    border: 2px dashed var(--success);
    color: white;
}

.btn-add-item:hover {
    background: #059669;
    border-color: #059669;
}

.add-item-form {
    background: var(--bg);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 0.75rem;
}

.add-item-form h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

/* Fade out animation for deleted items */
@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

/* Print Styles */
@media print {
    .header, .actions-bar, .btn {
        display: none !important;
    }

    .newsletter-preview {
        padding: 0;
        box-shadow: none;
    }

    .top-five-section {
        background: #f8f9fa !important;
        border: 1px solid #333;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Hide all edit controls when printing */
    .item-controls,
    .item-edit-form,
    .edit-mode .newsletter-item {
        border: none !important;
        padding: 0 !important;
    }

    .item-controls,
    .add-item-section {
        display: none !important;
    }
}
