/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #ff6b35;
    --secondary-color: #f7931e;
    --accent-color: #ff8c42;
    --text-dark: #2d1e1e;
    --text-light: #8b6f6f;
    --bg-light: #fff5f0;
    --bg-white: #ffffff;
    --border-color: #ffe4d6;
    --success-color: #ff6b6b;
    --danger-color: #ef4444;
    --gradient-1: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    --gradient-2: linear-gradient(135deg, #ff8c42 0%, #ff6b35 100%);
    --gradient-3: linear-gradient(135deg, #ffd6a5 0%, #ffadad 100%);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: var(--gradient-1);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background 0.3s;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
}

/* Hero Section */
.hero {
    background: var(--gradient-3);
    color: #2d1e1e;
    text-align: center;
    padding: 80px 20px;
    position: relative;
    overflow: hidden;
    animation: fadeIn 1s ease-out;
}

.hero::before {
    content: '💕';
    position: absolute;
    font-size: 150px;
    opacity: 0.1;
    top: -30px;
    right: 10%;
    animation: float 6s ease-in-out infinite;
}

.hero::after {
    content: '💖';
    position: absolute;
    font-size: 120px;
    opacity: 0.1;
    bottom: -20px;
    left: 5%;
    animation: float 8s ease-in-out infinite reverse;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Search Section */
.search-section {
    padding: 30px 0;
}

.search-box {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-box input {
    width: 100%;
    padding: 15px 15px 15px 45px;
    border: 2px solid var(--border-color);
    border-radius: 50px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.1);
    transform: scale(1.02);
}

/* Stories Section */
.stories-section {
    padding: 40px 0;
}

.section-title {
    font-size: 2rem;
    margin-bottom: 30px;
    color: var(--text-dark);
}

.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

.story-card {
    background: var(--bg-white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.1);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    border: 2px solid transparent;
    animation: cardAppear 0.6s ease-out forwards;
    opacity: 0;
}

@keyframes cardAppear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.story-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 12px 30px rgba(255, 107, 53, 0.3);
    border-color: var(--primary-color);
}

.story-card.placeholder {
    cursor: default;
}

.story-card.placeholder:hover {
    transform: none;
}

.story-cover {
    height: 220px;
    background: var(--gradient-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.story-cover::before {
    content: '💝';
    position: absolute;
    font-size: 100px;
    opacity: 0.2;
    top: -20px;
    right: -20px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.2; }
    50% { transform: scale(1.1); opacity: 0.3; }
}

.story-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-info {
    padding: 20px;
}

.story-info h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.story-info p {
    color: var(--text-light);
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.story-meta {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Reading Page */
.reading-container {
    background: white;
    min-height: calc(100vh - 200px);
    padding: 40px 0;
}

.story-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.story-title-reading {
    font-size: 2.5rem;
    color: var(--text-dark);
    margin-bottom: 15px;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.chapter-select {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

.reading-settings {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 12px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-group button,
.theme-btn {
    padding: 8px 15px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.setting-group button:hover,
.theme-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.theme-btn.light {
    background: #fff;
}

.theme-btn.sepia {
    background: #f4ecd8;
}

.theme-btn.dark {
    background: #1f2937;
    color: white;
}

.story-content {
    max-width: 800px;
    margin: 40px auto;
    padding: 40px;
    background: white;
    border-radius: 12px;
    font-size: 18px;
    line-height: 1.8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.story-content p {
    margin-bottom: 1.5rem;
    text-align: justify;
}

.story-content h1,
.story-content h2,
.story-content h3 {
    margin: 2rem 0 1rem 0;
    color: var(--text-dark);
}

/* Theme variations */
body.sepia .story-content {
    background: #f4ecd8;
    color: #5c4a2f;
}

body.dark .story-content {
    background: #1f2937;
    color: #e5e7eb;
}

body.dark {
    background: #111827;
    color: #e5e7eb;
}

/* Admin Page */
.admin-section {
    padding: 40px 0;
    min-height: calc(100vh - 200px);
}

.admin-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.admin-card h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.story-form {
    max-width: 600px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-light);
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:hover {
    background: var(--gradient-2);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.5);
}

.btn-secondary {
    background: var(--text-light);
    color: white;
}

.btn-secondary:hover {
    background: var(--text-dark);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Stories List */
.stories-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.story-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.story-item-info h4 {
    margin-bottom: 5px;
    color: var(--text-dark);
}

.story-item-info p {
    font-size: 0.9rem;
    color: var(--text-light);
}

.story-item-actions {
    display: flex;
    gap: 10px;
}

/* Instructions */
.instructions ol {
    margin-left: 20px;
}

.instructions li {
    margin-bottom: 15px;
    line-height: 1.6;
}

.instructions ul {
    margin: 10px 0 10px 20px;
}

/* Tags */
.tag {
    display: inline-block;
    padding: 4px 10px;
    background: var(--gradient-2);
    color: white;
    border-radius: 12px;
    font-size: 0.8rem;
    margin: 2px;
    transition: transform 0.2s;
}

.tag:hover {
    transform: scale(1.05);
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.tag-filter {
    cursor: pointer;
    border: 2px solid transparent;
}

.tag-filter.active {
    border-color: white;
    box-shadow: 0 0 10px rgba(255, 107, 53, 0.5);
}

/* Messages */
.success-msg {
    color: var(--success-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-muted {
    color: var(--text-light);
}

/* Footer */
.footer {
    background: var(--text-dark);
    color: white;
    text-align: center;
    padding: 30px 0;
    margin-top: 60px;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h2 {
        font-size: 2rem;
    }

    .story-title-reading {
        font-size: 1.8rem;
    }

    .stories-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }

    .chapter-nav {
        flex-direction: column;
    }

    .chapter-select {
        width: 100%;
    }

    .reading-settings {
        flex-direction: column;
        gap: 15px;
    }

    .story-content {
        padding: 20px;
        font-size: 16px;
    }

    .story-item {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}
