/**
 * Valentine - Styles
 * Romantic yearbook design with flip animations
 */

/* ============================================
   Global Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #ff6b9d;
    --secondary-color: #ffc2d4;
    --accent-color: #c44569;
    --text-dark: #2c3e50;
    --text-light: #ffffff;
    --background: linear-gradient(135deg, #ffeef8 0%, #ffc2d4 100%);
    --shadow: 0 10px 30px rgba(196, 69, 105, 0.2);
    --shadow-heavy: 0 15px 50px rgba(196, 69, 105, 0.3);
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--background);
    color: var(--text-dark);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: hidden;
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--background);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-heavy);
    text-align: center;
}

.login-card h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.login-card p {
    color: var(--text-dark);
    margin-bottom: 30px;
    font-style: italic;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.login-card input[type="password"] {
    padding: 15px;
    border: 2px solid var(--secondary-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s;
}

.login-card input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 157, 0.1);
}

.login-card button {
    padding: 15px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.login-card button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.error-message {
    color: #e74c3c;
    background: #ffe0e0;
    padding: 10px;
    border-radius: 5px;
    display: none;
    margin-top: 10px;
}

.back-link {
    display: inline-block;
    margin-top: 20px;
    color: var(--accent-color);
    text-decoration: none;
    font-style: italic;
}

.back-link:hover {
    text-decoration: underline;
}

/* ============================================
   Book Container
   ============================================ */
.book-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 40px 20px;
    overflow: visible;
}

.book {
    position: relative;
    width: 95%;
    max-width: 1200px;
    height: 800px;
    background: white;
    border-radius: 15px;
    box-shadow: var(--shadow-heavy);
    perspective: 2000px;
    transform-style: preserve-3d;
    overflow: visible;
}

/* ============================================
   Page Styles
   ============================================ */
.page {
    position: absolute;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 15px;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 1.5s ease-in-out;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 40px 30px;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
}

.page.hidden-left {
    transform: rotateY(-180deg);
    pointer-events: none;
}

.page.hidden-right {
    transform: rotateY(0deg);
    z-index: 1;
}

.page.active {
    transform: rotateY(0deg);
    z-index: 10;
}

/* Set initial z-index for pages based on their order */
.page[data-page="0"] { z-index: 10; }
.page[data-page="1"] { z-index: 9; }
.page[data-page="2"] { z-index: 8; }
.page[data-page="3"] { z-index: 7; }
.page[data-page="4"] { z-index: 6; }
.page[data-page="5"] { z-index: 5; }
.page[data-page="6"] { z-index: 4; }
.page[data-page="7"] { z-index: 3; }
.page[data-page="8"] { z-index: 2; }
.page[data-page="9"] { z-index: 1; }

.page-content {
    width: 100%;
    max-width: 900px;
    text-align: center;
}

/* Multiple images in a romantic grid */
.page-images {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    margin-bottom: 20px;
    padding: 10px;
}

.page-image {
    border-radius: 15px;
    overflow: visible;
    max-width: 100%;
    position: relative;
}

.page-image.multiple {
    flex: 0 1 calc(50% - 20px);
    min-width: 250px;
    margin-bottom: 20px;
}

.page-image img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    display: block;
    border-radius: 12px;
    padding: 12px;
    background: white;
    box-shadow: 0 8px 24px rgba(196, 69, 105, 0.25);
    border: 3px solid var(--secondary-color);
    transition: transform 0.3s ease;
}

/* Romantic diagonal tilt for multiple images */
.page-image:nth-child(odd) img {
    transform: rotate(-2deg);
}

.page-image:nth-child(even) img {
    transform: rotate(2deg);
}

.page-image img:hover {
    transform: rotate(0deg) scale(1.05);
    box-shadow: 0 12px 32px rgba(196, 69, 105, 0.35);
}

.page-text h2 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    font-family: 'Brush Script MT', cursive;
}

.page-text p {
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--text-dark);
    font-style: italic;
    margin-bottom: 10px;
}

/* ============================================
   Navigation Buttons
   ============================================ */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 2000;
    box-shadow: var(--shadow);
    pointer-events: auto;
}

.nav-btn:hover {
    background: var(--accent-color);
    transform: translateY(-50%) scale(1.1);
}

.prev-btn {
    left: -70px;
}

.next-btn {
    right: -70px;
}

/* Adjust for smaller screens */
@media (max-width: 1400px) {
    .prev-btn {
        left: 10px;
    }
    
    .next-btn {
        right: 10px;
    }
}

/* ============================================
   Answer Section
   ============================================ */
.answer-section {
    margin-top: 40px;
    width: 100%;
}

.answer-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.answer-btn {
    padding: 20px 40px;
    font-size: 1.3rem;
    font-weight: bold;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

.yes-btn {
    background: linear-gradient(135deg, #ff6b9d, #c44569);
    color: white;
}

.yes-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: var(--shadow-heavy);
}

.no-btn {
    background: #e0e0e0;
    color: #666;
}

.no-btn:hover {
    background: #d0d0d0;
    transform: translateY(-2px);
}

.reason-section {
    margin-top: 30px;
    text-align: center;
}

.reason-section p {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: var(--accent-color);
}

.reason-section textarea {
    width: 100%;
    max-width: 500px;
    padding: 15px;
    border: 2px solid var(--secondary-color);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
}

.reason-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.reason-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.back-btn {
    padding: 12px 30px;
    background: #e0e0e0;
    color: #666;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.back-btn:hover {
    background: #d0d0d0;
    transform: translateY(-2px);
}

.submit-btn {
    padding: 12px 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.submit-btn:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

.thank-you-section h3 {
    font-size: 2rem;
    color: var(--primary-color);
    font-family: 'Brush Script MT', cursive;
}

/* ============================================
   Logout Button
   ============================================ */
.logout-btn-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.logout-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: var(--accent-color);
    color: white;
}

/* ============================================
   Admin Panel
   ============================================ */
.admin-page {
    background: #f5f5f5;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.admin-header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.admin-header h1 {
    color: var(--primary-color);
    font-size: 2rem;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.admin-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: var(--shadow);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--secondary-color);
}

.tab-btn {
    padding: 15px 30px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    color: #666;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-edit {
    background: #3498db;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-edit:hover {
    background: #2980b9;
}

.btn-delete {
    background: #e74c3c;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-delete:hover {
    background: #c0392b;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.section-header h2 {
    color: var(--primary-color);
}

/* Pages List */
.pages-list {
    display: grid;
    gap: 20px;
}

.page-item {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.page-info {
    flex: 1;
}

.page-info h3 {
    color: var(--text-dark);
    margin-bottom: 5px;
}

.page-info p {
    color: #666;
    font-size: 0.9rem;
}

.page-actions {
    display: flex;
    gap: 10px;
}

/* Responses List */
.responses-list {
    display: grid;
    gap: 20px;
}

.response-item {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 10px;
}

.response-item.answer-yes {
    border-left: 5px solid #27ae60;
}

.response-item.answer-no {
    border-left: 5px solid #e74c3c;
}

.response-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.response-answer {
    font-weight: bold;
    font-size: 1.2rem;
}

.response-answer.yes {
    color: #27ae60;
}

.response-answer.no {
    color: #e74c3c;
}

.response-date {
    color: #666;
    font-size: 0.9rem;
}

.response-reason {
    margin-top: 10px;
    padding: 15px;
    background: white;
    border-radius: 5px;
    font-style: italic;
}

/* Settings */
.settings-section {
    margin-bottom: 40px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
}

.settings-section h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.settings-section form {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.settings-section input {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    font-size: 1rem;
}

.settings-section input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.help-text {
    margin-top: 10px;
    color: #666;
    font-size: 0.85rem;
    font-style: italic;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: 15px;
    box-shadow: var(--shadow-heavy);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 2px solid var(--secondary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: var(--primary-color);
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.close-btn:hover {
    color: var(--accent-color);
}

.modal form {
    padding: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--text-dark);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-top: 2px solid var(--secondary-color);
}

#currentImage img {
    max-width: 200px;
    margin-top: 10px;
    border-radius: 8px;
}

/* Existing Images Container */
.existing-images-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    min-height: 50px;
}

.existing-images-container:empty::before {
    content: 'Inga bilder ännu';
    color: #999;
    font-style: italic;
}

.existing-image-item {
    position: relative;
    width: 150px;
}

.existing-image-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--secondary-color);
}

.delete-image-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.3s;
}

.delete-image-btn:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.image-upload-section {
    padding: 15px;
    background: #fff;
    border: 2px dashed var(--secondary-color);
    border-radius: 8px;
}

.image-mode-selector {
    margin-top: 15px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
}

.image-mode-selector label {
    display: block;
    margin-bottom: 10px;
    cursor: pointer;
    font-weight: normal;
}

.image-mode-selector input[type="radio"] {
    margin-right: 8px;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .book {
        width: 95%;
        height: 650px;
    }
    
    .page {
        padding: 30px 20px;
    }
    
    .page-image img {
        max-height: 300px;
    }
    
    .page-image.multiple {
        flex: 0 1 100%;
    }
    
    .page-text h2 {
        font-size: 1.8rem;
    }
    
    .page-text p {
        font-size: 1rem;
    }
    
    .answer-btn {
        padding: 15px 30px;
        font-size: 1.1rem;
    }
    
    .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .page-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 30px 20px;
    }
    
    .book {
        height: 600px;
    }
    
    .page {
        padding: 25px 15px;
    }
    
    .page-image img {
        max-height: 250px;
        padding: 8px;
    }
    
    .page-text h2 {
        font-size: 1.5rem;
    }
    
    .answer-buttons {
        flex-direction: column;
    }
    
    .reason-buttons {
        flex-direction: column;
    }
    
    .settings-section form {
        flex-direction: column;
    }
}
