/* ===== VARIABLES ===== */
:root {
    --purple: #7c5caa;
    --purple-light: #9d85c0;
    --purple-dark: #5a4080;
    --yellow: #f5b800;
    --yellow-hover: #e5ac00;
    --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;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
}

/* ===== RESET ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

/* ===== LOGIN ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.login-box h1 {
    color: var(--purple);
    font-size: 28px;
    margin-bottom: 8px;
}

.login-box .subtitle {
    color: var(--gray-500);
    margin-bottom: 32px;
}

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

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 16px;
    transition: border-color 0.2s;
}

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

.error-message {
    color: #dc2626;
    font-size: 14px;
    margin-bottom: 16px;
    min-height: 20px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--yellow);
    color: var(--gray-800);
}

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

.btn-full {
    width: 100%;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    font-size: 16px;
}

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

.btn-danger:hover {
    background: #fee2e2;
    color: #dc2626;
}

.btn-copy {
    padding: 6px 12px;
    font-size: 12px;
    background: var(--gray-100);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--gray-600);
}

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

/* ===== HEADER ===== */
.header {
    background: var(--white);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    font-size: 20px;
    font-weight: 600;
    color: var(--purple);
}

.brand-name {
    color: var(--gray-500);
    padding-left: 16px;
    border-left: 1px solid var(--gray-200);
}

.back-link {
    color: var(--gray-500);
    text-decoration: none;
    font-size: 14px;
}

.back-link:hover {
    color: var(--purple);
}

.header-nav {
    display: flex;
    gap: 24px;
}

.header-nav a {
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
}

.header-nav a:hover {
    color: var(--purple);
}

/* ===== MAIN ===== */
.main {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.selection-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--purple-light);
    border-radius: var(--radius);
    color: white;
}

.selection-controls span {
    font-size: 14px;
    font-weight: 500;
}

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

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

.btn-text {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.8;
}

.btn-text:hover {
    opacity: 1;
}

.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: var(--radius);
}

.tab {
    padding: 8px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-600);
    transition: all 0.2s;
}

.tab.active {
    background: var(--white);
    color: var(--gray-800);
    box-shadow: var(--shadow);
}

/* ===== STATUS MESSAGE ===== */
.status-message {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 14px;
}

.status-message.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.status-message.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.hidden {
    display: none !important;
}

/* ===== ARTICLES GRID ===== */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.article-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    position: relative;
}

.article-card:hover {
    border-color: var(--purple-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.article-card.has-content {
    border-left: 4px solid var(--purple);
}

.article-card.selected {
    border-color: var(--purple);
    background: #f9f7fc;
}

.article-select {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
}

.checkbox {
    display: block;
    width: 22px;
    height: 22px;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    background: white;
    transition: all 0.2s;
}

.checkbox:hover {
    border-color: var(--purple);
}

.checkbox.checked {
    background: var(--purple);
    border-color: var(--purple);
}

.checkbox.checked::after {
    content: '✓';
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
    height: 100%;
}

.article-source {
    font-size: 12px;
    color: var(--purple);
    font-weight: 500;
    margin-bottom: 8px;
}

.article-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 12px;
    line-height: 1.4;
}

.article-snippet {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.article-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.article-link {
    font-size: 18px;
    color: var(--gray-400);
    text-decoration: none;
    transition: color 0.2s;
}

.article-link:hover {
    color: var(--purple);
}

.article-date {
    font-size: 12px;
    color: var(--gray-400);
}

.article-favorite {
    font-size: 20px;
    cursor: pointer;
    opacity: 0.3;
    transition: all 0.2s;
}

.article-favorite:hover,
.article-favorite.active {
    opacity: 1;
}

.loading {
    text-align: center;
    padding: 48px;
    color: var(--gray-400);
}

.empty {
    text-align: center;
    padding: 48px;
    color: var(--gray-400);
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
    z-index: 10;
}

.modal-close:hover {
    background: var(--gray-200);
}

.modal-header {
    padding: 32px 32px 24px;
    border-bottom: 1px solid var(--gray-100);
}

.modal-header h2 {
    font-size: 22px;
    color: var(--gray-800);
    margin-bottom: 12px;
    padding-right: 40px;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--gray-500);
}

.modal-meta a {
    color: var(--purple);
    text-decoration: none;
}

.modal-body {
    padding: 24px 32px 32px;
}

.snippet {
    color: var(--gray-600);
    margin-bottom: 32px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

/* ===== CONTENT SECTIONS ===== */
.content-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.content-section {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.section-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
}

.section-content {
    padding: 16px;
    min-height: 80px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.section-content .placeholder {
    color: var(--gray-400);
    font-style: italic;
}

.section-content.loading {
    color: var(--gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
}

.content-section .btn-copy {
    margin: 0 16px 16px;
}

.image-actions {
    padding: 0 16px 16px;
    display: flex;
    gap: 8px;
}

.generated-image {
    max-width: 100%;
    border-radius: 8px;
}

/* ===== ADMIN ===== */
.admin-main {
    max-width: 900px;
}

.admin-grid {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.admin-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}

.admin-section h2 {
    font-size: 18px;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.section-desc {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 24px;
}

.add-form {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.add-form input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 15px;
}

.add-form input:focus {
    outline: none;
    border-color: var(--purple);
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: 8px;
}

.item.inactive {
    opacity: 0.5;
}

.item-name {
    font-weight: 500;
}

.item-actions {
    display: flex;
    gap: 4px;
}

textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 12px;
}

textarea:focus {
    outline: none;
    border-color: var(--purple);
}

.form-hint {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 20px;
}

.save-status {
    margin-left: 16px;
    font-size: 14px;
    color: var(--gray-500);
}

/* ===== COMBINE MODAL ===== */
.modal-subtitle {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

.combine-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.combine-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: 8px;
}

.combine-source {
    font-size: 12px;
    color: var(--purple);
    font-weight: 500;
    white-space: nowrap;
}

.combine-title {
    font-size: 14px;
    color: var(--gray-700);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.combine-hint {
    background: #fef9e7;
    border: 1px solid #f7dc6f;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
}

.combine-hint p {
    margin: 0;
    font-size: 14px;
    color: #7d6608;
}

.ai-sources {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
    font-size: 12px;
    color: var(--gray-500);
}

.ai-sources a {
    color: var(--purple);
    text-decoration: none;
}

.ai-sources a:hover {
    text-decoration: underline;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
    }
    
    .main {
        padding: 16px;
    }
    
    .controls {
        flex-direction: column;
        gap: 16px;
    }
    
    .articles-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
    
    .modal-header,
    .modal-body {
        padding: 20px;
    }
    
    .add-form {
        flex-direction: column;
    }
}
