* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ===== PAGES ===== */
.page {
    display: none;
    flex-direction: column;
    animation: fadeIn 0.3s ease-in;
}

.page.active {
    display: flex;
    flex: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-buttons {
    display: flex;
    gap: 10px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-title {
    flex: 1;
    text-align: center;
    font-size: 28px;
    font-weight: bold;
}

/* ===== AUTHENTICATION ===== */
.auth-button-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 110px;
    justify-content: flex-end;
}

.btn-login {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.btn-login:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.auth-status-mini {
    font-size: 18px;
    display: none;
}

.auth-status-mini.authenticated {
    display: inline;
}

.login-modal-content {
    max-width: 400px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.login-form label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.login-form input {
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.login-form input:focus {
    outline: none;
    border-color: #2ecc71;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.1);
}

.auth-status {
    padding: 10px 15px;
    border-radius: 5px;
    text-align: center;
    font-size: 14px;
    display: none;
}

.auth-status.show {
    display: block;
}

.auth-status.error {
    background: #ffe5e5;
    color: #c0392b;
}

.auth-status.authenticated {
    background: #d5f4e6;
    color: #27ae60;
}

/* ===== GALLERY ===== */
.gallery {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    align-content: start;
}

.card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.card-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-image-placeholder {
    font-size: 60px;
    color: rgba(255, 255, 255, 0.5);
}

.card-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.card-description {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
    flex: 1;
    line-height: 1.5;
}

.card-actions {
    display: flex;
    gap: 10px;
}

.card-actions.hidden {
    display: none;
}

.btn-delete {
    flex: 1;
    padding: 8px 12px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.btn-delete:hover {
    background: #c0392b;
}

.add-card-btn {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s ease;
    min-height: 280px;
}

.add-card-btn:hover:not(.disabled) {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(46, 204, 113, 0.3);
}

.add-card-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ===== DETAIL PAGE ===== */
.detail-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.detail-title {
    font-size: 32px;
    color: #333;
}

.btn-primary {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.rich-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    line-height: 1.8;
    color: #555;
    font-size: 16px;
}

.rich-content img {
    max-width: 300px;
    float: left;
    margin: 10px 15px 10px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rich-content iframe {
    margin: 15px 0;
    border-radius: 8px;
}

/* ===== EDIT PAGE ===== */
.edit-page {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.edit-title-section {
    margin-bottom: 20px;
}

.edit-title-input {
    width: 100%;
    font-size: 28px;
    font-weight: bold;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.edit-title-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ===== EDITOR TOOLBAR ===== */
.editor-toolbar {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #e9ecef;
}

.toolbar-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toolbar-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    font-weight: 600;
}

.toolbar-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.color-picker {
    width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
}

/* ===== EDITOR ===== */
.editor-container {
    flex: 1;
    margin-bottom: 15px;
}

.rich-editor {
    width: 100%;
    min-height: 400px;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.8;
    overflow-y: auto;
    background: white;
    transition: all 0.3s ease;
}

.rich-editor:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.rich-editor img {
    max-width: 300px;
    float: left;
    margin: 10px 15px 10px 0;
    cursor: grab;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rich-editor img.selected {
    outline: 3px solid #667eea;
}

.rich-editor img:hover {
    cursor: grab;
}

/* ===== EDIT ACTIONS ===== */
.edit-actions {
    display: flex;
    gap: 10px;
}

.btn-save, .btn-cancel {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-save {
    background: #2ecc71;
    color: white;
}

.btn-save:hover {
    background: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.btn-cancel {
    background: #95a5a6;
    color: white;
}

.btn-cancel:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(149, 165, 166, 0.3);
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* ===== IMAGE UPLOAD ===== */
.image-upload-area {
    width: 100%;
    border: 2px dashed #667eea;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-upload-area:hover {
    background: #eef2ff;
    border-color: #764ba2;
}

.image-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.image-upload-placeholder p {
    color: #666;
    font-size: 14px;
}

#imagePreview {
    cursor: pointer;
}

/* ===== CROP MODAL ===== */
.crop-container {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
    background: #f0f0f0;
    border-radius: 8px;
    overflow: hidden;
}

#cropImage {
    width: 100%;
    display: block;
}

.crop-box {
    position: absolute;
    border: 2px solid #667eea;
    background: rgba(102, 126, 234, 0.1);
    cursor: move;
    display: none;
}

.crop-box.active {
    display: block;
}

.crop-instructions {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.3s ease;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .gallery {
        grid-template-columns: 1fr;
        padding: 15px;
        gap: 15px;
    }

    .page-title {
        font-size: 20px;
    }

    .detail-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .detail-title {
        font-size: 24px;
    }

    .detail-content {
        padding: 15px;
    }

    .edit-page {
        padding: 15px;
    }

    .editor-toolbar {
        flex-direction: column;
        gap: 10px;
    }

    .rich-editor {
        min-height: 300px;
    }

    .auth-form {
        flex-direction: column;
    }

    .auth-form input {
        min-width: 100%;
    }

    .auth-status {
        min-width: 100%;
    }

    .modal-content {
        width: 95%;
    }

    .header {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .page-title {
        font-size: 18px;
    }

    .card-title {
        font-size: 16px;
    }

    .detail-title {
        font-size: 20px;
    }

    .btn-icon {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    .toolbar-group {
        flex: 1;
        width: 100%;
    }

    .toolbar-btn {
        flex: 1;
    }
}
